Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4509)

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/media/ui/MediaNotificationManager.java

Issue 1679923005: Re-enable volume control for Android Cast (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Respond to comments Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/android/java/src/org/chromium/chrome/browser/media/ui/MediaNotificationManager.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/media/ui/MediaNotificationManager.java b/chrome/android/java/src/org/chromium/chrome/browser/media/ui/MediaNotificationManager.java
index b9fc49c583b796eab93e8cd723cdbc5d8aa5f254..82d69c37366a7c40f12047546b5f2849c49b3093 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/media/ui/MediaNotificationManager.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/media/ui/MediaNotificationManager.java
@@ -23,6 +23,7 @@ import android.support.v4.app.NotificationManagerCompat;
import android.support.v4.media.MediaMetadataCompat;
import android.support.v4.media.session.MediaSessionCompat;
import android.support.v4.media.session.PlaybackStateCompat;
+import android.support.v7.media.MediaRouter;
import android.util.SparseArray;
import android.view.KeyEvent;
import android.view.View;
@@ -595,9 +596,20 @@ public class MediaNotificationManager {
mMediaNotificationInfo.isPrivate ? NotificationCompat.VISIBILITY_PRIVATE
: NotificationCompat.VISIBILITY_PUBLIC);
+
if (mMediaNotificationInfo.supportsPlayPause()) {
- if (mMediaSession == null) mMediaSession = createMediaSession();
+ if (mMediaSession == null) mMediaSession = createMediaSession();
+ try {
+ // Tell the MediaRouter about the session, so that Chrome can control the volume
+ // on the remote cast device (if any).
+ // Pre-MR1 versions of JB do not have the complete MediaRouter APIs,
+ // so getting the MediaRouter instance will throw an exception.
+ MediaRouter.getInstance(mContext).setMediaSessionCompat(mMediaSession);
+ } catch (NoSuchMethodError e) {
+ // Do nothing. Chrome can't be casting without a MediaRouter, so there is nothing
+ // to do here.
+ }
mMediaSession.setMetadata(createMetadata());
PlaybackStateCompat.Builder playbackStateBuilder = new PlaybackStateCompat.Builder()
@@ -606,7 +618,6 @@ public class MediaNotificationManager {
playbackStateBuilder.setState(PlaybackStateCompat.STATE_PAUSED,
PlaybackStateCompat.PLAYBACK_POSITION_UNKNOWN, 1.0f);
} else {
- // If notification only supports stop, still pretend
playbackStateBuilder.setState(PlaybackStateCompat.STATE_PLAYING,
PlaybackStateCompat.PLAYBACK_POSITION_UNKNOWN, 1.0f);
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698