react-native-sound does not work in production build for iOS but works within emulator and for production android










0















I'm working on a React Native application which plays back voicemails. I'm running into an issue with our production app. It does not play back the voicemails on the production iOS or testflight builds, however it will play back on the production build of android as well as the emulator for iOS and Android. I'm relatively new to react-native applications so I'm trying to figure out why this would be occurring.



The app does not crash, it shows the playback as occurring in the UI but no audio is played.



What are specific things to check regarding a production build not being able to play sound?



I am on the current version of react-native-sound which is currently 0.10.9.



Here is my togglePlay function which uses Sound from react-native-sound. I have imported it.



togglePlay()



 if (this.state.vmLoaded == false) 

if (this.state.vmLoading == true)
return;


if (this.state.vmLoading == false)

this.setState( vmLoading: true );

Requester.getVoicemail(this.props.vmData, this.props.token, 'stream')
.then((res) =>

this.setState(
vmPath: res,
vmLoaded: true,
);

const vm = new Sound(res, '', (error) =>

if (error)

// Show toast if voicemail did not load
Toast( message: 'Failed to load voicemail' );
else

if (!this.state.vmStarted)

this.setState( vmStarted: true );


vm.play((success) =>

if (success)

this.setState(
vmPlaying: false,
currentTime: this.state.vmLength / 1000,
);

// Clears the interval timer to keep thread
// from keeping track of timing
timer.clearInterval(this, 'playingInt');
else

// if call recording fails to play, show toast to user
Toast( message: 'Failed to play recording' );

);

this.setState( vmPlaying: true );

// if loaded successfully, set the instance of Sound as STATE vm
// allowing calls to the instance via this.state.vm
// ie: this.state.vm.play() will initiate playing the sound
this.setState(
// set instance of Sound to state
vm,
// set full length of recording to state
vmLength: vm.getDuration(),
// set current playing time of recording to state (new, so zero)
currentTime: 0,
// interval is still null until sound is played
interval: null,
// sound starts off paused (no audio)
vmPlaying: true,
// Finally, the recording has been loaded, setting
// this so another instance is not created on
// rerender (see above IF statements)
vmLoaded: true,
vmLoading: false,
);

);
).then(() =>

timer.clearInterval(this, 'playingInt');

interval: timer.setInterval(this, 'playingInt', () =>

this.state.vm.getCurrentTime((seconds) =>

this.setState( currentTime: seconds );
);
, 1000);
);

else if (this.state.vmLoaded == true)

if (this.state.vmPlaying == true)

this.state.vm.pause();

this.setState( vmPlaying: false );

timer.clearInterval(this, 'playingInt');
else

this.state.vm.play();

this.setState( vmPlaying: true );

timer.clearInterval(this, 'playingInt');

interval: timer.setInterval(this, 'playingInt', () =>

this.state.vm.getCurrentTime((seconds) =>

this.setState( currentTime: seconds );
);
, 1000);





Please let me know if other information would be helpful in debugging this.



Thank you










share|improve this question
























  • Update: When the app is deleted and then rebuilt the sound does not play on ios but any subsequent builds to the app (without deleting it) will allow the sound to play.

    – brooks
    Nov 13 '18 at 0:14











  • Why do you provide your package.json ? Isn't your question about react-native-sound ? What exact version of it do you use / is resolved in your package-lock.json ? Could you provide the Javascript code where you use it ? We use react-native-sound, and we had no problems so far (except with codepush releases on android...)

    – Vinzzz
    Nov 13 '18 at 9:40











  • @Vinzzz I updated my question with the updated info you asked for. I call togglePlay() within a ToughableHighlight component. Again this works great on Android builds but not on iOS. Thanks for your help

    – brooks
    Nov 13 '18 at 18:06











  • You didn't provide the react-native-sound part, this is only some react component. Do you use require as sound filePath? How do you embed sounds in you app bundle ?

    – Vinzzz
    Nov 14 '18 at 0:48











  • I figured out the issue for this. Sound was coming out of the speaker on the phone instead of the earpiece and the ringer was muted. I added `Sound.setCategory("Playback") to allow the sound to still play back even when the ringer was muted. Thank you for offering to assist this problem @Vinzzz

    – brooks
    Nov 15 '18 at 16:20















0















I'm working on a React Native application which plays back voicemails. I'm running into an issue with our production app. It does not play back the voicemails on the production iOS or testflight builds, however it will play back on the production build of android as well as the emulator for iOS and Android. I'm relatively new to react-native applications so I'm trying to figure out why this would be occurring.



The app does not crash, it shows the playback as occurring in the UI but no audio is played.



What are specific things to check regarding a production build not being able to play sound?



I am on the current version of react-native-sound which is currently 0.10.9.



Here is my togglePlay function which uses Sound from react-native-sound. I have imported it.



togglePlay()



 if (this.state.vmLoaded == false) 

if (this.state.vmLoading == true)
return;


if (this.state.vmLoading == false)

this.setState( vmLoading: true );

Requester.getVoicemail(this.props.vmData, this.props.token, 'stream')
.then((res) =>

this.setState(
vmPath: res,
vmLoaded: true,
);

const vm = new Sound(res, '', (error) =>

if (error)

// Show toast if voicemail did not load
Toast( message: 'Failed to load voicemail' );
else

if (!this.state.vmStarted)

this.setState( vmStarted: true );


vm.play((success) =>

if (success)

this.setState(
vmPlaying: false,
currentTime: this.state.vmLength / 1000,
);

// Clears the interval timer to keep thread
// from keeping track of timing
timer.clearInterval(this, 'playingInt');
else

// if call recording fails to play, show toast to user
Toast( message: 'Failed to play recording' );

);

this.setState( vmPlaying: true );

// if loaded successfully, set the instance of Sound as STATE vm
// allowing calls to the instance via this.state.vm
// ie: this.state.vm.play() will initiate playing the sound
this.setState(
// set instance of Sound to state
vm,
// set full length of recording to state
vmLength: vm.getDuration(),
// set current playing time of recording to state (new, so zero)
currentTime: 0,
// interval is still null until sound is played
interval: null,
// sound starts off paused (no audio)
vmPlaying: true,
// Finally, the recording has been loaded, setting
// this so another instance is not created on
// rerender (see above IF statements)
vmLoaded: true,
vmLoading: false,
);

);
).then(() =>

timer.clearInterval(this, 'playingInt');

interval: timer.setInterval(this, 'playingInt', () =>

this.state.vm.getCurrentTime((seconds) =>

this.setState( currentTime: seconds );
);
, 1000);
);

else if (this.state.vmLoaded == true)

if (this.state.vmPlaying == true)

this.state.vm.pause();

this.setState( vmPlaying: false );

timer.clearInterval(this, 'playingInt');
else

this.state.vm.play();

this.setState( vmPlaying: true );

timer.clearInterval(this, 'playingInt');

interval: timer.setInterval(this, 'playingInt', () =>

this.state.vm.getCurrentTime((seconds) =>

this.setState( currentTime: seconds );
);
, 1000);





Please let me know if other information would be helpful in debugging this.



Thank you










share|improve this question
























  • Update: When the app is deleted and then rebuilt the sound does not play on ios but any subsequent builds to the app (without deleting it) will allow the sound to play.

    – brooks
    Nov 13 '18 at 0:14











  • Why do you provide your package.json ? Isn't your question about react-native-sound ? What exact version of it do you use / is resolved in your package-lock.json ? Could you provide the Javascript code where you use it ? We use react-native-sound, and we had no problems so far (except with codepush releases on android...)

    – Vinzzz
    Nov 13 '18 at 9:40











  • @Vinzzz I updated my question with the updated info you asked for. I call togglePlay() within a ToughableHighlight component. Again this works great on Android builds but not on iOS. Thanks for your help

    – brooks
    Nov 13 '18 at 18:06











  • You didn't provide the react-native-sound part, this is only some react component. Do you use require as sound filePath? How do you embed sounds in you app bundle ?

    – Vinzzz
    Nov 14 '18 at 0:48











  • I figured out the issue for this. Sound was coming out of the speaker on the phone instead of the earpiece and the ringer was muted. I added `Sound.setCategory("Playback") to allow the sound to still play back even when the ringer was muted. Thank you for offering to assist this problem @Vinzzz

    – brooks
    Nov 15 '18 at 16:20













0












0








0








I'm working on a React Native application which plays back voicemails. I'm running into an issue with our production app. It does not play back the voicemails on the production iOS or testflight builds, however it will play back on the production build of android as well as the emulator for iOS and Android. I'm relatively new to react-native applications so I'm trying to figure out why this would be occurring.



The app does not crash, it shows the playback as occurring in the UI but no audio is played.



What are specific things to check regarding a production build not being able to play sound?



I am on the current version of react-native-sound which is currently 0.10.9.



Here is my togglePlay function which uses Sound from react-native-sound. I have imported it.



togglePlay()



 if (this.state.vmLoaded == false) 

if (this.state.vmLoading == true)
return;


if (this.state.vmLoading == false)

this.setState( vmLoading: true );

Requester.getVoicemail(this.props.vmData, this.props.token, 'stream')
.then((res) =>

this.setState(
vmPath: res,
vmLoaded: true,
);

const vm = new Sound(res, '', (error) =>

if (error)

// Show toast if voicemail did not load
Toast( message: 'Failed to load voicemail' );
else

if (!this.state.vmStarted)

this.setState( vmStarted: true );


vm.play((success) =>

if (success)

this.setState(
vmPlaying: false,
currentTime: this.state.vmLength / 1000,
);

// Clears the interval timer to keep thread
// from keeping track of timing
timer.clearInterval(this, 'playingInt');
else

// if call recording fails to play, show toast to user
Toast( message: 'Failed to play recording' );

);

this.setState( vmPlaying: true );

// if loaded successfully, set the instance of Sound as STATE vm
// allowing calls to the instance via this.state.vm
// ie: this.state.vm.play() will initiate playing the sound
this.setState(
// set instance of Sound to state
vm,
// set full length of recording to state
vmLength: vm.getDuration(),
// set current playing time of recording to state (new, so zero)
currentTime: 0,
// interval is still null until sound is played
interval: null,
// sound starts off paused (no audio)
vmPlaying: true,
// Finally, the recording has been loaded, setting
// this so another instance is not created on
// rerender (see above IF statements)
vmLoaded: true,
vmLoading: false,
);

);
).then(() =>

timer.clearInterval(this, 'playingInt');

interval: timer.setInterval(this, 'playingInt', () =>

this.state.vm.getCurrentTime((seconds) =>

this.setState( currentTime: seconds );
);
, 1000);
);

else if (this.state.vmLoaded == true)

if (this.state.vmPlaying == true)

this.state.vm.pause();

this.setState( vmPlaying: false );

timer.clearInterval(this, 'playingInt');
else

this.state.vm.play();

this.setState( vmPlaying: true );

timer.clearInterval(this, 'playingInt');

interval: timer.setInterval(this, 'playingInt', () =>

this.state.vm.getCurrentTime((seconds) =>

this.setState( currentTime: seconds );
);
, 1000);





Please let me know if other information would be helpful in debugging this.



Thank you










share|improve this question
















I'm working on a React Native application which plays back voicemails. I'm running into an issue with our production app. It does not play back the voicemails on the production iOS or testflight builds, however it will play back on the production build of android as well as the emulator for iOS and Android. I'm relatively new to react-native applications so I'm trying to figure out why this would be occurring.



The app does not crash, it shows the playback as occurring in the UI but no audio is played.



What are specific things to check regarding a production build not being able to play sound?



I am on the current version of react-native-sound which is currently 0.10.9.



Here is my togglePlay function which uses Sound from react-native-sound. I have imported it.



togglePlay()



 if (this.state.vmLoaded == false) 

if (this.state.vmLoading == true)
return;


if (this.state.vmLoading == false)

this.setState( vmLoading: true );

Requester.getVoicemail(this.props.vmData, this.props.token, 'stream')
.then((res) =>

this.setState(
vmPath: res,
vmLoaded: true,
);

const vm = new Sound(res, '', (error) =>

if (error)

// Show toast if voicemail did not load
Toast( message: 'Failed to load voicemail' );
else

if (!this.state.vmStarted)

this.setState( vmStarted: true );


vm.play((success) =>

if (success)

this.setState(
vmPlaying: false,
currentTime: this.state.vmLength / 1000,
);

// Clears the interval timer to keep thread
// from keeping track of timing
timer.clearInterval(this, 'playingInt');
else

// if call recording fails to play, show toast to user
Toast( message: 'Failed to play recording' );

);

this.setState( vmPlaying: true );

// if loaded successfully, set the instance of Sound as STATE vm
// allowing calls to the instance via this.state.vm
// ie: this.state.vm.play() will initiate playing the sound
this.setState(
// set instance of Sound to state
vm,
// set full length of recording to state
vmLength: vm.getDuration(),
// set current playing time of recording to state (new, so zero)
currentTime: 0,
// interval is still null until sound is played
interval: null,
// sound starts off paused (no audio)
vmPlaying: true,
// Finally, the recording has been loaded, setting
// this so another instance is not created on
// rerender (see above IF statements)
vmLoaded: true,
vmLoading: false,
);

);
).then(() =>

timer.clearInterval(this, 'playingInt');

interval: timer.setInterval(this, 'playingInt', () =>

this.state.vm.getCurrentTime((seconds) =>

this.setState( currentTime: seconds );
);
, 1000);
);

else if (this.state.vmLoaded == true)

if (this.state.vmPlaying == true)

this.state.vm.pause();

this.setState( vmPlaying: false );

timer.clearInterval(this, 'playingInt');
else

this.state.vm.play();

this.setState( vmPlaying: true );

timer.clearInterval(this, 'playingInt');

interval: timer.setInterval(this, 'playingInt', () =>

this.state.vm.getCurrentTime((seconds) =>

this.setState( currentTime: seconds );
);
, 1000);





Please let me know if other information would be helpful in debugging this.



Thank you







android ios react-native react-native-sound






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 13 '18 at 18:52







brooks

















asked Nov 12 '18 at 18:50









brooksbrooks

12




12












  • Update: When the app is deleted and then rebuilt the sound does not play on ios but any subsequent builds to the app (without deleting it) will allow the sound to play.

    – brooks
    Nov 13 '18 at 0:14











  • Why do you provide your package.json ? Isn't your question about react-native-sound ? What exact version of it do you use / is resolved in your package-lock.json ? Could you provide the Javascript code where you use it ? We use react-native-sound, and we had no problems so far (except with codepush releases on android...)

    – Vinzzz
    Nov 13 '18 at 9:40











  • @Vinzzz I updated my question with the updated info you asked for. I call togglePlay() within a ToughableHighlight component. Again this works great on Android builds but not on iOS. Thanks for your help

    – brooks
    Nov 13 '18 at 18:06











  • You didn't provide the react-native-sound part, this is only some react component. Do you use require as sound filePath? How do you embed sounds in you app bundle ?

    – Vinzzz
    Nov 14 '18 at 0:48











  • I figured out the issue for this. Sound was coming out of the speaker on the phone instead of the earpiece and the ringer was muted. I added `Sound.setCategory("Playback") to allow the sound to still play back even when the ringer was muted. Thank you for offering to assist this problem @Vinzzz

    – brooks
    Nov 15 '18 at 16:20

















  • Update: When the app is deleted and then rebuilt the sound does not play on ios but any subsequent builds to the app (without deleting it) will allow the sound to play.

    – brooks
    Nov 13 '18 at 0:14











  • Why do you provide your package.json ? Isn't your question about react-native-sound ? What exact version of it do you use / is resolved in your package-lock.json ? Could you provide the Javascript code where you use it ? We use react-native-sound, and we had no problems so far (except with codepush releases on android...)

    – Vinzzz
    Nov 13 '18 at 9:40











  • @Vinzzz I updated my question with the updated info you asked for. I call togglePlay() within a ToughableHighlight component. Again this works great on Android builds but not on iOS. Thanks for your help

    – brooks
    Nov 13 '18 at 18:06











  • You didn't provide the react-native-sound part, this is only some react component. Do you use require as sound filePath? How do you embed sounds in you app bundle ?

    – Vinzzz
    Nov 14 '18 at 0:48











  • I figured out the issue for this. Sound was coming out of the speaker on the phone instead of the earpiece and the ringer was muted. I added `Sound.setCategory("Playback") to allow the sound to still play back even when the ringer was muted. Thank you for offering to assist this problem @Vinzzz

    – brooks
    Nov 15 '18 at 16:20
















Update: When the app is deleted and then rebuilt the sound does not play on ios but any subsequent builds to the app (without deleting it) will allow the sound to play.

– brooks
Nov 13 '18 at 0:14





Update: When the app is deleted and then rebuilt the sound does not play on ios but any subsequent builds to the app (without deleting it) will allow the sound to play.

– brooks
Nov 13 '18 at 0:14













Why do you provide your package.json ? Isn't your question about react-native-sound ? What exact version of it do you use / is resolved in your package-lock.json ? Could you provide the Javascript code where you use it ? We use react-native-sound, and we had no problems so far (except with codepush releases on android...)

– Vinzzz
Nov 13 '18 at 9:40





Why do you provide your package.json ? Isn't your question about react-native-sound ? What exact version of it do you use / is resolved in your package-lock.json ? Could you provide the Javascript code where you use it ? We use react-native-sound, and we had no problems so far (except with codepush releases on android...)

– Vinzzz
Nov 13 '18 at 9:40













@Vinzzz I updated my question with the updated info you asked for. I call togglePlay() within a ToughableHighlight component. Again this works great on Android builds but not on iOS. Thanks for your help

– brooks
Nov 13 '18 at 18:06





@Vinzzz I updated my question with the updated info you asked for. I call togglePlay() within a ToughableHighlight component. Again this works great on Android builds but not on iOS. Thanks for your help

– brooks
Nov 13 '18 at 18:06













You didn't provide the react-native-sound part, this is only some react component. Do you use require as sound filePath? How do you embed sounds in you app bundle ?

– Vinzzz
Nov 14 '18 at 0:48





You didn't provide the react-native-sound part, this is only some react component. Do you use require as sound filePath? How do you embed sounds in you app bundle ?

– Vinzzz
Nov 14 '18 at 0:48













I figured out the issue for this. Sound was coming out of the speaker on the phone instead of the earpiece and the ringer was muted. I added `Sound.setCategory("Playback") to allow the sound to still play back even when the ringer was muted. Thank you for offering to assist this problem @Vinzzz

– brooks
Nov 15 '18 at 16:20





I figured out the issue for this. Sound was coming out of the speaker on the phone instead of the earpiece and the ringer was muted. I added `Sound.setCategory("Playback") to allow the sound to still play back even when the ringer was muted. Thank you for offering to assist this problem @Vinzzz

– brooks
Nov 15 '18 at 16:20












1 Answer
1






active

oldest

votes


















0














The problem had to to do with the manual switch to mute the ringer on iPhone. Sound was being played back through the speakerphone. I added `Sound.setCategory("Playback") after Sound was initialized to allow the sound to still play back even with the ringer muted.






share|improve this answer






















    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53268344%2freact-native-sound-does-not-work-in-production-build-for-ios-but-works-within-em%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    The problem had to to do with the manual switch to mute the ringer on iPhone. Sound was being played back through the speakerphone. I added `Sound.setCategory("Playback") after Sound was initialized to allow the sound to still play back even with the ringer muted.






    share|improve this answer



























      0














      The problem had to to do with the manual switch to mute the ringer on iPhone. Sound was being played back through the speakerphone. I added `Sound.setCategory("Playback") after Sound was initialized to allow the sound to still play back even with the ringer muted.






      share|improve this answer

























        0












        0








        0







        The problem had to to do with the manual switch to mute the ringer on iPhone. Sound was being played back through the speakerphone. I added `Sound.setCategory("Playback") after Sound was initialized to allow the sound to still play back even with the ringer muted.






        share|improve this answer













        The problem had to to do with the manual switch to mute the ringer on iPhone. Sound was being played back through the speakerphone. I added `Sound.setCategory("Playback") after Sound was initialized to allow the sound to still play back even with the ringer muted.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 15 '18 at 16:22









        brooksbrooks

        12




        12



























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53268344%2freact-native-sound-does-not-work-in-production-build-for-ios-but-works-within-em%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Use pre created SQLite database for Android project in kotlin

            Darth Vader #20

            Ondo