Commit 1699876a by bachinger Committed by Oliver Woodman

call stop(true) when media action stop is received

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=205377624
parent 0721d372
/* /*
* Copyright (c) 2017 The Android Open Source Project * Copyright (C) 2017 The Android Open Source Project
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -127,7 +127,7 @@ public class DefaultPlaybackController implements MediaSessionConnector.Playback ...@@ -127,7 +127,7 @@ public class DefaultPlaybackController implements MediaSessionConnector.Playback
@Override @Override
public void onStop(Player player) { public void onStop(Player player) {
player.stop(); player.stop(true);
} }
@Override @Override
......
...@@ -689,13 +689,16 @@ public final class MediaSessionConnector { ...@@ -689,13 +689,16 @@ public final class MediaSessionConnector {
@Override @Override
public MediaMetadataCompat getMetadata(Player player) { public MediaMetadataCompat getMetadata(Player player) {
if (player.getCurrentTimeline().isEmpty()) {
return null;
}
MediaMetadataCompat.Builder builder = new MediaMetadataCompat.Builder(); MediaMetadataCompat.Builder builder = new MediaMetadataCompat.Builder();
if (player != null && player.isPlayingAd()) { if (player.isPlayingAd()) {
builder.putLong(MediaMetadataCompat.METADATA_KEY_ADVERTISEMENT, 1); builder.putLong(MediaMetadataCompat.METADATA_KEY_ADVERTISEMENT, 1);
} }
builder.putLong( builder.putLong(
MediaMetadataCompat.METADATA_KEY_DURATION, MediaMetadataCompat.METADATA_KEY_DURATION,
player == null ? 0 : player.getDuration() == C.TIME_UNSET ? -1 : player.getDuration()); player.getDuration() == C.TIME_UNSET ? -1 : player.getDuration());
long activeQueueItemId = mediaController.getPlaybackState().getActiveQueueItemId(); long activeQueueItemId = mediaController.getPlaybackState().getActiveQueueItemId();
if (activeQueueItemId != MediaSessionCompat.QueueItem.UNKNOWN_ID) { if (activeQueueItemId != MediaSessionCompat.QueueItem.UNKNOWN_ID) {
List<MediaSessionCompat.QueueItem> queue = mediaController.getQueue(); List<MediaSessionCompat.QueueItem> queue = mediaController.getQueue();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment