diff options
author | Scott Jackson <daneren2005@gmail.com> | 2014-09-24 14:59:44 -0700 |
---|---|---|
committer | Scott Jackson <daneren2005@gmail.com> | 2014-09-24 14:59:44 -0700 |
commit | 31c4502c2b0b012a3aa8d6a06b788c937e44e6f1 (patch) | |
tree | 6838ffcfee24d9bc85093a914bcff3fbf82a1ec5 /src | |
parent | fe916d7fbfd3b99c11d8874ade375da89bccc9a3 (diff) | |
download | dsub-31c4502c2b0b012a3aa8d6a06b788c937e44e6f1.tar.gz dsub-31c4502c2b0b012a3aa8d6a06b788c937e44e6f1.tar.bz2 dsub-31c4502c2b0b012a3aa8d6a06b788c937e44e6f1.zip |
#287 Try to recreate mediaPlayer, apply EQ, then resume on failure to initialize EQ
Diffstat (limited to 'src')
-rw-r--r-- | src/github/daneren2005/dsub/service/DownloadService.java | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/src/github/daneren2005/dsub/service/DownloadService.java b/src/github/daneren2005/dsub/service/DownloadService.java index 798b4541..dc256c5b 100644 --- a/src/github/daneren2005/dsub/service/DownloadService.java +++ b/src/github/daneren2005/dsub/service/DownloadService.java @@ -1009,6 +1009,10 @@ public class DownloadService extends Service { } mediaPlayer.setOnErrorListener(null); mediaPlayer.setOnCompletionListener(null); + if(Build.VERSION.SKD_INT >= Build.VERSION_CODES.JELLY_BEAN && nextSetup) { + mediaPlayer.setNextMediaPlayer(null); + nextSetup = false; + } mediaPlayer.reset(); subtractPosition = 0; } catch (Exception x) { @@ -1198,7 +1202,26 @@ public class DownloadService extends Service { } public EqualizerController getEqualizerController() { - return effectsController.getEqualizerController(); + try { + return effectsController.getEqualizerController(); + } catch(Exception e) { + // If we failed, we are going to try to reinitialize the MediaPlayer + boolean playing = playerState == STARTED; + int pos = getPlayerPosition(); + reset(); + + EqualizerController controller; + try { + controller = effectsController.getEqualizerController(); + } catch(Exception e) { + // Don't try again, just resetup media player + } + + // Restart from same position and state we left off in + play(getCurrentPlayingIndex(), playing, pos); + + return controller; + } } public MediaRouteSelector getRemoteSelector() { |