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)
|
### dev-v2 (not yet released)
|
||||||
|
|
||||||
* Core library:
|
* Core library:
|
||||||
|
* Implement getTag for SilenceMediaSource.
|
||||||
* Add `Player.getTrackSelector` to access track selector from UI module.
|
* Add `Player.getTrackSelector` to access track selector from UI module.
|
||||||
* Added `TextComponent.getCurrentCues` because the current cues are no
|
* Added `TextComponent.getCurrentCues` because the current cues are no
|
||||||
longer forwarded to a new `TextOutput` in `SimpleExoPlayer`
|
longer forwarded to a new `TextOutput` in `SimpleExoPlayer`
|
||||||
|
@ -151,6 +151,12 @@ public final class SilenceMediaSource extends BaseMediaSource {
|
|||||||
return mediaItem;
|
return mediaItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public Object getTag() {
|
||||||
|
return Assertions.checkNotNull(mediaItem.playbackProperties).tag;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void releaseSourceInternal() {}
|
protected void releaseSourceInternal() {}
|
||||||
|
|
||||||
|
@ -52,6 +52,16 @@ public class SilenceMediaSourceTest {
|
|||||||
assertThat(mediaSource.getMediaItem().playbackProperties.tag).isEqualTo(tag);
|
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
|
@Test
|
||||||
public void builder_setDurationUsNotCalled_throwsIllegalStateException() {
|
public void builder_setDurationUsNotCalled_throwsIllegalStateException() {
|
||||||
assertThrows(IllegalStateException.class, new SilenceMediaSource.Factory()::createMediaSource);
|
assertThrows(IllegalStateException.class, new SilenceMediaSource.Factory()::createMediaSource);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user