mirror of
https://github.com/androidx/media.git
synced 2025-04-30 06:46:50 +08:00
Fix bug where SilenceMediaSource#getTag was always returning null.
SilenceMediaSource never overloaded MediaSource#getTag, and default behavior is to return null. PiperOrigin-RevId: 314779832
This commit is contained in:
parent
1dedd080a4
commit
08b0e08b69
@ -3,6 +3,7 @@
|
||||
### dev-v2 (not yet released)
|
||||
|
||||
* Core library:
|
||||
* Implement getTag for SilenceMediaSource.
|
||||
* Add `Player.getTrackSelector` to access track selector from UI module.
|
||||
* Added `TextComponent.getCurrentCues` because the current cues are no
|
||||
longer forwarded to a new `TextOutput` in `SimpleExoPlayer`
|
||||
|
@ -151,6 +151,12 @@ public final class SilenceMediaSource extends BaseMediaSource {
|
||||
return mediaItem;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Object getTag() {
|
||||
return Assertions.checkNotNull(mediaItem.playbackProperties).tag;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void releaseSourceInternal() {}
|
||||
|
||||
|
@ -52,6 +52,16 @@ public class SilenceMediaSourceTest {
|
||||
assertThat(mediaSource.getMediaItem().playbackProperties.tag).isEqualTo(tag);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void builderSetTag_setsTagOfMediaSource() {
|
||||
Object tag = new Object();
|
||||
|
||||
SilenceMediaSource mediaSource =
|
||||
new SilenceMediaSource.Factory().setTag(tag).setDurationUs(1_000_000).createMediaSource();
|
||||
|
||||
assertThat(mediaSource.getMediaItem().playbackProperties.tag).isEqualTo(tag);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void builder_setDurationUsNotCalled_throwsIllegalStateException() {
|
||||
assertThrows(IllegalStateException.class, new SilenceMediaSource.Factory()::createMediaSource);
|
||||
|
Loading…
x
Reference in New Issue
Block a user