react-native-audio-toolkit: RCTJSONStringify Error when playing stream

Hello!
I’am running in to an issue where I’am receiving the error message:

RCTJSONStringify() encountered the following error: Invalid number value (NaN) in JSON write
reactConsoleErrorHandler @ ExceptionsManager.js:71
console.error @ YellowBox.js:67
logToConsole @ RCTLog.js:45
logIfNoNativeHook @ RCTLog.js:31
__callFunction @ MessageQueue.js:245
(anonymous) @ MessageQueue.js:101
__guard @ MessageQueue.js:213
callFunctionReturnFlushedQueue @ MessageQueue.js:100
(anonymous) @ debuggerWorker.js:71

This only occurs when I’am streaming from an IceCast server MP3 stream. The error does not occur if I use a mp3 url from cloudfront.

Setup to reproduce the error:

import {
    Player
} from 'react-native-audio-toolkit';

let url = 'http://webradio.antennevorarlberg.at/live';
let p = new Player(url, {
  autoDestroy: true,
  continuesToPlayInBackground: true
});
p.play();

In the Info.plist add:

<key>NSExceptionDomains</key>
<dict>
    <key>antennevorarlberg.at</key>
    <dict>
        <key>NSExceptionAllowsInsecureHTTPLoads</key>
        <true/>
        <key>NSIncludeSubdomains</key>
        <true/>
    </dict>
</dict>

My guess is React Native is not liking it when 0 is being passed as the duration, since the streams have no set end time. I have not tested this on Android yet.

Thank you for a great library! Please let me know if you need additional information about my setup.

Dependencies: React: 16.0.0 React-Native: 0.45.1 React-Native-Audio-Toolkit: 1.0.5 iOS: 10 iPhone 6

About this issue

  • Original URL
  • State: open
  • Created 7 years ago
  • Reactions: 7
  • Comments: 22

Most upvoted comments

I will carve out a quick moment to put together a PR. Thanks for the input.

OK. That library seems to do a whole bunch of other things.

@futurice, any fixes coming for this?

This error was raised for me, but only in my simulator, and completely unexpectedly; I’ve been using this library in many places around my app, loading the audio in the same way from the same remote endpoint, but in one specific instance this error would be thrown. I confirmed it wasn’t present in the build.

I was just noting that this thoughtful solution deserved it’s own PR 😃

@RassaLibre That library no longer exists. Any other ideas?

@RassaLibre I ended up moving to a new library which has been working out very well. https://github.com/react-native-kit/react-native-track-player.

This problem occurs because your server doesn’t support partial request.

Try react-native-track-player.