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
1 changed files with 14 additions and 1 deletions

View File

@ -610,13 +610,26 @@ public class LocalPSMP extends PlaybackServiceMediaPlayer {
executor.shutdown(); executor.shutdown();
if (mediaPlayer != null) { if (mediaPlayer != null) {
try { try {
removeMediaPlayerErrorListener();
if (mediaPlayer.isPlaying()) {
mediaPlayer.stop(); mediaPlayer.stop();
}
} catch (Exception ignore) { } } catch (Exception ignore) { }
mediaPlayer.release(); mediaPlayer.release();
} }
releaseWifiLockIfNecessary(); 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. * 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. * This method is executed on an internal executor service.