Bug 1322114 - Part 2: handle more media state change r=alwu
authorJulian_Chu <walkingice0204@gmail.com>
Thu, 12 Jan 2017 14:54:05 +0800
changeset 358477 daf0f6eccbb6cf6e5f5ab74c99c569e174168ec8
parent 358476 63bf33197a074d1a3fff623fdecea63ca7db282a
child 358478 c69a94671a4afc639d5969b7a744ba4ae6e0b239
push id10621
push userjlund@mozilla.com
push dateMon, 23 Jan 2017 16:02:43 +0000
treeherdermozilla-aurora@dca7b42e6c67 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersalwu
bugs1322114
milestone53.0a1
Bug 1322114 - Part 2: handle more media state change r=alwu 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
mobile/android/base/java/org/mozilla/gecko/media/MediaControlService.java
--- 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);
                 }