Bug 1357639 - part1 : change tab's media playing state when the tab is controlled by media control. r=sebastian
☠☠ backed out by 90becadc7978 ☠ ☠
authorAlastor Wu <alwu@mozilla.com>
Thu, 04 May 2017 15:19:39 +0800
changeset 573121 6fa5520670a334c592e83d19305b0b83933ba9bc
parent 573120 8f8cb62a874903f66603da14326bfc52326c30f9
child 573122 608cca1e60592b4468fcf47ce71822fc65befac8
push id57306
push userbmo:emilio+bugs@crisal.io
push dateFri, 05 May 2017 10:08:55 +0000
reviewerssebastian
bugs1357639
milestone55.0a1
Bug 1357639 - part1 : change tab's media playing state when the tab is controlled by media control. r=sebastian MozReview-Commit-ID: 7CNbMdCJT3K
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
@@ -330,26 +330,35 @@ public class MediaControlService extends
                 setState(State.STOPPED);
                 notifyObservers("mediaControl", "mediaControlStopped");
                 mTabReference = new WeakReference<>(null);
             }
         });
 
     }
 
+    private void setMediaStateForTab(boolean isTabPlaying) {
+        final Tab tab = mTabReference.get();
+        if (tab == null) {
+            return;
+        }
+        tab.setIsMediaPlaying(isTabPlaying);
+    }
+
     private void notifyObservers(String topic, String data) {
         GeckoAppShell.notifyObservers(topic, data);
     }
 
     private boolean isNeedToRemoveControlInterface(State state) {
         return state.equals(State.STOPPED);
     }
 
     private void setState(State newState) {
         mMediaState = newState;
+        setMediaStateForTab(mMediaState.equals(State.PLAYING));
         onStateChanged();
     }
 
     private void onStateChanged() {
         if (!mInitialize) {
             return;
         }