React-native-track-player: Player stop for no reason while pressing pause button on notification

Created on 27 Nov 2017  路  4Comments  路  Source: react-native-kit/react-native-track-player

I have yet to find a way to reproduce this bug but when I play a stream and I navigate on my cell phone. Some times when pressing pause button. The notification just desapear like if I press the stop button.

After debugging a bit, i found that the react-native app is restarting. It is maybe related to my implementation of the plugin but I do not understand why this is happening some time on some android device.

Android Bug

Most helpful comment

This happens because, for some reason, the headless task makes the app crash.
https://github.com/react-native-kit/react-native-track-player/issues/94

I already have three solutions in mind, I'll be trying them in a new branch.

All 4 comments

Do you have any stacktraces for this issue? Which platform are you using? Device?

This happens because, for some reason, the headless task makes the app crash.
https://github.com/react-native-kit/react-native-track-player/issues/94

I already have three solutions in mind, I'll be trying them in a new branch.

I thing can't Handle event, In My case this is working for me

AppRegistry.registerHeadlessTask('TrackPlayer', () =>
module.exports = async (data) => {
if(data.type === 'playback-state') {
// Update the UI with the new state
} else if(data.type === 'remote-play') {
_player = false;
TrackPlayer.play();
} else if(data.type === 'remote-pause') {
TrackPlayer.pause();
_player = true;
} else if(data.type === 'remote-stop') {
TrackPlayer.stop();
} else if(data.type === 'remote-seek') {
console.warn(data.position);
TrackPlayer.seekTo(data.position);
} else if(data.type === 'remote-next') {
TrackPlayer.skipToNext();
} else if(data.type === 'remote-previous') {
TrackPlayer.skipToPrevious();
}
}
);

This should be solved as part of release v1.0.0

Was this page helpful?
0 / 5 - 0 ratings