mirror of
https://github.com/androidx/media.git
synced 2025-04-30 06:46:50 +08:00
Add device info to CastPlayer
Issue: androidx/media#142 PiperOrigin-RevId: 468666737 (cherry picked from commit d204f6bf7e94bbfb8eaa0b312b4b95f74010841e)
This commit is contained in:
parent
373ac4c7bd
commit
24d35a4bef
@ -63,6 +63,10 @@
|
||||
* Update CMake version to avoid incompatibilities with the latest Android
|
||||
Studio releases
|
||||
([#9933](https://github.com/google/ExoPlayer/issues/9933)).
|
||||
* Cast extension:
|
||||
* Implement `getDeviceInfo()` to be able to identify `CastPlayer` when
|
||||
controlling playback with a `MediaController`
|
||||
([#142](https://github.com/google/ExoPlayer/issues/142)).
|
||||
|
||||
### 1.0.0-beta02 (2022-07-15)
|
||||
|
||||
|
@ -82,6 +82,10 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
|
||||
@UnstableApi
|
||||
public final class CastPlayer extends BasePlayer {
|
||||
|
||||
/** The {@link DeviceInfo} returned by {@link #getDeviceInfo() this player}. */
|
||||
public static final DeviceInfo DEVICE_INFO =
|
||||
new DeviceInfo(DeviceInfo.PLAYBACK_TYPE_REMOTE, /* minVolume= */ 0, /* maxVolume= */ 0);
|
||||
|
||||
static {
|
||||
MediaLibraryInfo.registerModule("media3.cast");
|
||||
}
|
||||
@ -729,10 +733,10 @@ public final class CastPlayer extends BasePlayer {
|
||||
return CueGroup.EMPTY_TIME_ZERO;
|
||||
}
|
||||
|
||||
/** This method is not supported and always returns {@link DeviceInfo#UNKNOWN}. */
|
||||
/** This method always returns {@link CastPlayer#DEVICE_INFO}. */
|
||||
@Override
|
||||
public DeviceInfo getDeviceInfo() {
|
||||
return DeviceInfo.UNKNOWN;
|
||||
return DEVICE_INFO;
|
||||
}
|
||||
|
||||
/** This method is not supported and always returns {@code 0}. */
|
||||
|
@ -62,6 +62,7 @@ import static org.mockito.MockitoAnnotations.initMocks;
|
||||
|
||||
import android.net.Uri;
|
||||
import androidx.media3.common.C;
|
||||
import androidx.media3.common.DeviceInfo;
|
||||
import androidx.media3.common.MediaItem;
|
||||
import androidx.media3.common.MediaMetadata;
|
||||
import androidx.media3.common.MimeTypes;
|
||||
@ -1864,6 +1865,14 @@ public class CastPlayerTest {
|
||||
verify(mockListener, never()).onMediaMetadataChanged(any());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getDeviceInfo_returnsCorrectDeviceInfoWithPlaybackTypeRemote() {
|
||||
DeviceInfo deviceInfo = castPlayer.getDeviceInfo();
|
||||
|
||||
assertThat(deviceInfo).isEqualTo(CastPlayer.DEVICE_INFO);
|
||||
assertThat(deviceInfo.playbackType).isEqualTo(DeviceInfo.PLAYBACK_TYPE_REMOTE);
|
||||
}
|
||||
|
||||
private int[] createMediaQueueItemIds(int numberOfIds) {
|
||||
int[] mediaQueueItemIds = new int[numberOfIds];
|
||||
for (int i = 0; i < numberOfIds; i++) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user