React-native-sound: Pause sound when minimized

Created on 21 Oct 2017  路  1Comment  路  Source: zmxv/react-native-sound

I've tried all variations of setCategory and the sound just won't stop when the app is minimized on both iOS and Android. One can use AppState to pause it manually but I'm wondering if there is a sound category that will prevent the sound from playing when the app is minimized?

Most helpful comment

This issue is a bit old now but for anyone passing by you can use Appstate to determine if the app is suspended and stop the music that way:

componentDidMount() {
    AppState.addEventListener('change', (state) => {
      if(state === 'background'){
        this.mainMusic.stop()
      }
    })
  }

>All comments

This issue is a bit old now but for anyone passing by you can use Appstate to determine if the app is suspended and stop the music that way:

componentDidMount() {
    AppState.addEventListener('change', (state) => {
      if(state === 'background'){
        this.mainMusic.stop()
      }
    })
  }
Was this page helpful?
0 / 5 - 0 ratings

Related issues

facuacostag picture facuacostag  路  10Comments

zakster12 picture zakster12  路  16Comments

paulmelnikow picture paulmelnikow  路  18Comments

badpenguin picture badpenguin  路  21Comments

FatemeKhodayari picture FatemeKhodayari  路  12Comments