Bug 1322114 - Part 2: handle more media state change
When the playing-media changes (ie. in Youtube click another
video when it is alreay playing one), there will be one more
event MEDIA_PLAYING_CHANGE, and the tab is still playing media.
This fix is to handle this situation then update state.
MozReview-Commit-ID: Aje2BBqFZKE
--- a/mobile/android/base/java/org/mozilla/gecko/media/MediaControlService.java
+++ b/mobile/android/base/java/org/mozilla/gecko/media/MediaControlService.java
@@ -115,19 +115,19 @@ public class MediaControlService extends
final Tab playingTab = mTabReference.get();
switch (msg) {
case MEDIA_PLAYING_CHANGE:
// The 'MEDIA_PLAYING_CHANGE' would only be received when the
// media starts or ends.
if (playingTab != tab && tab.isMediaPlaying()) {
mTabReference = new WeakReference<>(tab);
setState(State.PLAYING);
- } else if (playingTab == tab && !tab.isMediaPlaying()) {
- mTabReference = new WeakReference<>(null);
- setState(State.STOPPED);
+ } else if (playingTab == tab) {
+ mTabReference = new WeakReference<>(tab.isMediaPlaying() ? tab : null);
+ setState(tab.isMediaPlaying() ? State.PLAYING : State.STOPPED);
}
break;
case MEDIA_PLAYING_RESUME:
// user resume the paused-by-control media from page so that we
// should make the control interface consistent.
if (playingTab == tab && !isMediaPlaying()) {
setState(State.PLAYING);
}