mirror of
https://github.com/AntennaPod/AntennaPod.git
synced 2024-12-25 16:23:54 +01:00
Merge pull request #3122 from ByteHamster/anr-switch-player
Made sure that there is not an ANR when switching media player
This commit is contained in:
commit
a03bf4cfc9
@ -20,6 +20,8 @@ import com.google.android.gms.cast.ApplicationMetadata;
|
||||
import com.google.android.libraries.cast.companionlibrary.cast.BaseCastManager;
|
||||
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
|
||||
import de.danoeh.antennapod.core.cast.CastConsumer;
|
||||
import de.danoeh.antennapod.core.cast.CastManager;
|
||||
@ -188,8 +190,8 @@ public class PlaybackServiceFlavorHelper {
|
||||
PlaybackServiceMediaPlayer mediaPlayer = callback.getMediaPlayer();
|
||||
if (mediaPlayer != null) {
|
||||
try {
|
||||
mediaPlayer.stopPlayback(false).get();
|
||||
} catch (InterruptedException | ExecutionException e) {
|
||||
mediaPlayer.stopPlayback(false).get(2, TimeUnit.SECONDS);
|
||||
} catch (InterruptedException | ExecutionException | TimeoutException e) {
|
||||
Log.e(TAG, "There was a problem stopping playback while switching media players", e);
|
||||
}
|
||||
mediaPlayer.shutdownQuietly();
|
||||
|
Loading…
Reference in New Issue
Block a user