Backed out changeset 09bbdb107c10 (bug 1222907) for mulet bustage
authorCarsten "Tomcat" Book <cbook@mozilla.com>
Fri, 13 Nov 2015 15:12:30 +0100
changeset 308796 58e6110ac261d0d968819b84fda9e9d841388847
parent 308795 aa91027325cffe624985e45374cb363791a1be2f
child 308797 94334352f9fac8641975a23d756dda348e017e63
push id7526
push usermleibovic@mozilla.com
push dateFri, 13 Nov 2015 20:37:49 +0000
bugs1222907
milestone45.0a1
backs out09bbdb107c10aff33668d6dbfefed29e1dd707e0
Backed out changeset 09bbdb107c10 (bug 1222907) for mulet bustage
mobile/android/base/ChromeCast.java
mobile/android/base/MediaCastingBar.java
mobile/android/chrome/content/CastingApps.js
mobile/android/modules/MediaPlayerApp.jsm
--- a/mobile/android/base/ChromeCast.java
+++ b/mobile/android/base/ChromeCast.java
@@ -81,33 +81,23 @@ class ChromeCast implements GeckoMediaPl
             this.type = type;
             this.title = title;
             this.callback = callback;
         }
 
         @Override
         public void onStatusUpdated() {
             MediaStatus mediaStatus = remoteMediaPlayer.getMediaStatus();
+            boolean isPlaying = mediaStatus.getPlayerState() == MediaStatus.PLAYER_STATE_PLAYING;
 
-            switch (mediaStatus.getPlayerState()) {
-            case MediaStatus.PLAYER_STATE_PLAYING:
-                GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("MediaPlayer:Playing", null));
-                break;
-            case MediaStatus.PLAYER_STATE_PAUSED:
-                GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("MediaPlayer:Paused", null));
-                break;
-            case MediaStatus.PLAYER_STATE_IDLE:
-                // TODO: Do we want to shutdown when there are errors?
-                if (mediaStatus.getIdleReason() == MediaStatus.IDLE_REASON_FINISHED) {
-                    GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("Casting:Stop", null));
-                }
-                break;
-            default:
-                // TODO: Do we need to handle other status such as buffering / unknown?
-                break;
+            // TODO: Do we want to shutdown when there are errors?
+            if (mediaStatus.getPlayerState() == MediaStatus.PLAYER_STATE_IDLE &&
+                mediaStatus.getIdleReason() == MediaStatus.IDLE_REASON_FINISHED) {
+
+                GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("Casting:Stop", null));
             }
         }
 
         @Override
         public void onMetadataUpdated() { }
 
         @Override
         public void onResult(ApplicationConnectionResult result) {
--- a/mobile/android/base/MediaCastingBar.java
+++ b/mobile/android/base/MediaCastingBar.java
@@ -29,18 +29,16 @@ public class MediaCastingBar extends Rel
 
     private boolean mInflated;
 
     public MediaCastingBar(Context context, AttributeSet attrs) {
         super(context, attrs);
 
         EventDispatcher.getInstance().registerGeckoThreadListener(this,
             "Casting:Started",
-            "Casting:Paused",
-            "Casting:Playing",
             "Casting:Stopped");
     }
 
     public void inflateContent() {
         LayoutInflater inflater = LayoutInflater.from(getContext());
         View content = inflater.inflate(R.layout.media_casting, this);
 
         mMediaPlay = (ImageButton) content.findViewById(R.id.media_play);
@@ -68,18 +66,16 @@ public class MediaCastingBar extends Rel
 
     public void hide() {
         setVisibility(GONE);
     }
 
     public void onDestroy() {
         EventDispatcher.getInstance().unregisterGeckoThreadListener(this,
             "Casting:Started",
-            "Casting:Paused",
-            "Casting:Playing",
             "Casting:Stopped");
     }
 
     // View.OnClickListener implementation
     @Override
     public void onClick(View v) {
         final int viewId = v.getId();
 
@@ -110,21 +106,15 @@ public class MediaCastingBar extends Rel
                         mCastingTo.setText(device);
                     } else {
                         // Should not happen
                         mCastingTo.setText("");
                         Log.d(LOGTAG, "Device name is empty.");
                     }
                     mMediaPlay.setVisibility(GONE);
                     mMediaPause.setVisibility(VISIBLE);
-                } else if (event.equals("Casting:Paused")) {
-                    mMediaPause.setVisibility(GONE);
-                    mMediaPlay.setVisibility(VISIBLE);
-                } else if (event.equals("Casting:Playing")) {
-                    mMediaPlay.setVisibility(GONE);
-                    mMediaPause.setVisibility(VISIBLE);
                 } else if (event.equals("Casting:Stopped")) {
                     hide();
                 }
             }
         });
     }
 }
--- a/mobile/android/chrome/content/CastingApps.js
+++ b/mobile/android/chrome/content/CastingApps.js
@@ -740,21 +740,13 @@ var CastingApps = {
   },
 
   onRemoteMediaStatus: function(aRemoteMedia) {
     if (!this.session) {
       return;
     }
 
     let status = aRemoteMedia.status;
-    switch (status) {
-      case "started":
-        Messaging.sendRequest({ type: "Casting:Playing" });
-        break;
-      case "paused":
-        Messaging.sendRequest({ type: "Casting:Paused" });
-        break;
-      case "completed":
-        this.closeExternal();
-        break;
+    if (status == "completed") {
+      this.closeExternal();
     }
   }
 };
--- a/mobile/android/modules/MediaPlayerApp.jsm
+++ b/mobile/android/modules/MediaPlayerApp.jsm
@@ -78,19 +78,16 @@ function RemoteMedia(id, listener) {
     Services.tm.mainThread.dispatch((function() {
       this._listener.onRemoteMediaStart(this);
     }).bind(this), Ci.nsIThread.DISPATCH_NORMAL);
   }
 }
 
 RemoteMedia.prototype = {
   shutdown: function shutdown() {
-    Services.obs.removeObserver(this, "MediaPlayer:Playing");
-    Services.obs.removeObserver(this, "MediaPlayer:Paused");
-
     this._send("MediaPlayer:End", {}, (result, err) => {
       this._status = "shutdown";
       if ("onRemoteMediaStop" in this._listener) {
         this._listener.onRemoteMediaStop(this);
       }
     });
   },
 
@@ -121,46 +118,21 @@ RemoteMedia.prototype = {
   load: function load(aData) {
     this._send("MediaPlayer:Load", aData, (result, err) => {
       if (err) {
         Cu.reportError("Can't load " + err);
         this.shutdown();
         return;
       }
 
-      Services.obs.addObserver(this, "MediaPlayer:Playing", false);
-      Services.obs.addObserver(this, "MediaPlayer:Paused", false);
       this._status = "started";
     })
   },
 
   get status() {
     return this._status;
   },
 
-  observe: function (aSubject, aTopic, aData) {
-    switch (aTopic) {
-      case "MediaPlayer:Playing":
-        if (this._status !== "started") {
-          this._status = "started";
-          if ("onRemoteMediaStatus" in this._listener) {
-            this._listener.onRemoteMediaStatus(this);
-          }
-        }
-        break;
-      case "MediaPlayer:Paused":
-        if (this._status !== "paused") {
-          this._status = "paused";
-          if ("onRemoteMediaStatus" in this._listener) {
-            this._listener.onRemoteMediaStatus(this);
-          }
-        }
-        break;
-      default:
-        break;
-    }
-  },
-
   _send: function(msg, data, callback) {
     data.id = this._id;
     send(msg, data, callback);
   }
 }