mirror of
https://github.com/samsonjs/media.git
synced 2026-04-02 10:45:51 +00:00
Use identical media item for constructor if possible
If no deprecated methods on the factory is called, the media item instance that is passed to the createMediaSource method must be passed down to the constructor of the media source. PiperOrigin-RevId: 314193865
This commit is contained in:
parent
2f3c7cb85f
commit
75e54a452a
1 changed files with 10 additions and 7 deletions
|
|
@ -180,15 +180,18 @@ public final class ProgressiveMediaSource extends BaseMediaSource
|
|||
@Override
|
||||
public ProgressiveMediaSource createMediaSource(MediaItem mediaItem) {
|
||||
checkNotNull(mediaItem.playbackProperties);
|
||||
MediaItem.Builder builder = mediaItem.buildUpon();
|
||||
if (mediaItem.playbackProperties.tag == null) {
|
||||
builder.setTag(tag);
|
||||
}
|
||||
if (mediaItem.playbackProperties.customCacheKey == null) {
|
||||
builder.setCustomCacheKey(customCacheKey);
|
||||
boolean needsTag = mediaItem.playbackProperties.tag == null && tag != null;
|
||||
boolean needsCustomCacheKey =
|
||||
mediaItem.playbackProperties.customCacheKey == null && customCacheKey != null;
|
||||
if (needsTag && needsCustomCacheKey) {
|
||||
mediaItem = mediaItem.buildUpon().setTag(tag).setCustomCacheKey(customCacheKey).build();
|
||||
} else if (needsTag) {
|
||||
mediaItem = mediaItem.buildUpon().setTag(tag).build();
|
||||
} else if (needsCustomCacheKey) {
|
||||
mediaItem = mediaItem.buildUpon().setCustomCacheKey(customCacheKey).build();
|
||||
}
|
||||
return new ProgressiveMediaSource(
|
||||
builder.build(),
|
||||
mediaItem,
|
||||
dataSourceFactory,
|
||||
extractorsFactory,
|
||||
drmSessionManager,
|
||||
|
|
|
|||
Loading…
Reference in a new issue