| 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);
|
| }
|
|
|