If there's an incoming phone call and/or I answer a phone call, no events seem to be fired by the library to get it to pause (or resume when phone call is finished).
Please, try 311a907e5b511cdb7855491706dfa81ca3517276.
In the previous Android version, it used to call remote-pause on phone calls. Now, it should be calling remote-duck with additional properties:
paused: Whether you should be pausing or resuming the musicducking: Whether you should lower or restore the volume (for instance, a notification sound should make your app duck for a second)Seems to work perfectly -- I see the event firing, and I don't seem to need to do anything else from my side -- the app pauses and resumes nicely.
how do i implement remote-duck : paused ? @Guichaguri @jasongrishkoff
@shuvo0074 Here's a pseudo code:
if(event === 'remote-duck') {
if(data.paused) {
TrackPlayer.pause();
wasPlaying = true;
} else if(data.ducking) {
TrackPlayer.setVolume(0.5);
} else {
if(wasPlaying) {
TrackPlayer.play();
wasPlaying = false;
}
TrackPlayer.setVolume(1);
}
}
paused set to true, you should pause your app.ducking set to true, you should either lower the volume or pause the app. If it's a music app, you probably want to lower the volume, but if it's a podcast app, you probably want to pause it for a moment.Note that the event will never be triggered with both paused and ducking set to true. It's either one of them or none.
When getting a call/playing a music on an App/Youtube, it fires event remote-duck for pausing. But on call end/music stop, its doesn't fire remote-duck again for resuming it back.
Works perfectly for ducking(on/off) for lowering down the volume on notification/message.
@Jayiitb does it happen in 80b97301bf340fa29ab9d971b9781c81d578e243?
@Guichaguri Thanks a lot! It works perfectly for calls. 馃憤
But for the apps like Youtube, Play Music etc. it doesn't resume.
@Jayiitb they are also audio apps that hold the audio focus as long as they can, so it overrides ours, which is the expected behavior.
Most helpful comment
@shuvo0074 Here's a pseudo code:
pausedset to true, you should pause your app.duckingset to true, you should either lower the volume or pause the app. If it's a music app, you probably want to lower the volume, but if it's a podcast app, you probably want to pause it for a moment.Note that the event will never be triggered with both
pausedandduckingset to true. It's either one of them or none.