zmxv / react-native-sound

React Native module for playing sound clips
MIT License
2.78k stars 748 forks source link

ComponenetWillUnmount realease but stop #694

Closed rendiwijiatmoko closed 3 years ago

rendiwijiatmoko commented 3 years ago

:beetle: Description

i want to play audio and when move to other screen i want still playing until i open agian or open oother file audio

:beetle: What have you tried?

i try to unsubscribe using willunmount

:beetle: Please post your code:

componentWillUnmount(){
        if(this.sound){
            this.sound.release();
        }
        if(this.timeout){
            clearInterval(this.timeout);
        }
    }

:bulb: Possible solution

Is your issue with...

Are you using...

Which versions are you using?

Does the problem occur on...

akk7300 commented 3 years ago

You don't need to write release function for background playing;

componentWillUnmount(){ if(this.timeout){ clearInterval(this.timeout); } }