Do not call error handler when shutting down playback service

This commit is contained in:
ByteHamster 2018-06-10 10:31:51 +02:00
parent 9fb695822a
commit 1331c92c1d

View File

@ -610,13 +610,26 @@ public class LocalPSMP extends PlaybackServiceMediaPlayer {
executor.shutdown();
if (mediaPlayer != null) {
try {
mediaPlayer.stop();
removeMediaPlayerErrorListener();
if (mediaPlayer.isPlaying()) {
mediaPlayer.stop();
}
} catch (Exception ignore) { }
mediaPlayer.release();
}
releaseWifiLockIfNecessary();
}
private void removeMediaPlayerErrorListener() {
if (mediaPlayer instanceof VideoPlayer) {
VideoPlayer vp = (VideoPlayer) mediaPlayer;
vp.setOnErrorListener((mp, what, extra) -> true);
} else if (mediaPlayer instanceof AudioPlayer) {
AudioPlayer ap = (AudioPlayer) mediaPlayer;
ap.setOnErrorListener((mediaPlayer, i, i1) -> true);
}
}
/**
* Releases internally used resources. This method should only be called when the object is not used anymore.
* This method is executed on an internal executor service.