Commit 75e54a45 by bachinger Committed by Oliver Woodman

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
parent 2f3c7cb8
......@@ -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,
......
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