mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +00:00
Use MediaSourceFactory interface to simplify DownloadHelper
PiperOrigin-RevId: 248367983
This commit is contained in:
parent
8edce41ff3
commit
4ca670bed3
11 changed files with 179 additions and 180 deletions
|
|
@ -24,6 +24,7 @@ import com.google.android.exoplayer2.ExoPlayerFactory;
|
||||||
import com.google.android.exoplayer2.SimpleExoPlayer;
|
import com.google.android.exoplayer2.SimpleExoPlayer;
|
||||||
import com.google.android.exoplayer2.ext.ima.ImaAdsLoader;
|
import com.google.android.exoplayer2.ext.ima.ImaAdsLoader;
|
||||||
import com.google.android.exoplayer2.source.MediaSource;
|
import com.google.android.exoplayer2.source.MediaSource;
|
||||||
|
import com.google.android.exoplayer2.source.MediaSourceFactory;
|
||||||
import com.google.android.exoplayer2.source.ProgressiveMediaSource;
|
import com.google.android.exoplayer2.source.ProgressiveMediaSource;
|
||||||
import com.google.android.exoplayer2.source.ads.AdsMediaSource;
|
import com.google.android.exoplayer2.source.ads.AdsMediaSource;
|
||||||
import com.google.android.exoplayer2.source.dash.DashMediaSource;
|
import com.google.android.exoplayer2.source.dash.DashMediaSource;
|
||||||
|
|
@ -35,7 +36,7 @@ import com.google.android.exoplayer2.upstream.DefaultDataSourceFactory;
|
||||||
import com.google.android.exoplayer2.util.Util;
|
import com.google.android.exoplayer2.util.Util;
|
||||||
|
|
||||||
/** Manages the {@link ExoPlayer}, the IMA plugin and all video playback. */
|
/** Manages the {@link ExoPlayer}, the IMA plugin and all video playback. */
|
||||||
/* package */ final class PlayerManager implements AdsMediaSource.MediaSourceFactory {
|
/* package */ final class PlayerManager implements MediaSourceFactory {
|
||||||
|
|
||||||
private final ImaAdsLoader adsLoader;
|
private final ImaAdsLoader adsLoader;
|
||||||
private final DataSource.Factory dataSourceFactory;
|
private final DataSource.Factory dataSourceFactory;
|
||||||
|
|
@ -89,7 +90,7 @@ import com.google.android.exoplayer2.util.Util;
|
||||||
adsLoader.release();
|
adsLoader.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
// AdsMediaSource.MediaSourceFactory implementation.
|
// MediaSourceFactory implementation.
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MediaSource createMediaSource(Uri uri) {
|
public MediaSource createMediaSource(Uri uri) {
|
||||||
|
|
|
||||||
|
|
@ -50,6 +50,7 @@ import com.google.android.exoplayer2.offline.DownloadRequest;
|
||||||
import com.google.android.exoplayer2.source.BehindLiveWindowException;
|
import com.google.android.exoplayer2.source.BehindLiveWindowException;
|
||||||
import com.google.android.exoplayer2.source.ConcatenatingMediaSource;
|
import com.google.android.exoplayer2.source.ConcatenatingMediaSource;
|
||||||
import com.google.android.exoplayer2.source.MediaSource;
|
import com.google.android.exoplayer2.source.MediaSource;
|
||||||
|
import com.google.android.exoplayer2.source.MediaSourceFactory;
|
||||||
import com.google.android.exoplayer2.source.ProgressiveMediaSource;
|
import com.google.android.exoplayer2.source.ProgressiveMediaSource;
|
||||||
import com.google.android.exoplayer2.source.TrackGroupArray;
|
import com.google.android.exoplayer2.source.TrackGroupArray;
|
||||||
import com.google.android.exoplayer2.source.ads.AdsLoader;
|
import com.google.android.exoplayer2.source.ads.AdsLoader;
|
||||||
|
|
@ -570,8 +571,8 @@ public class PlayerActivity extends AppCompatActivity
|
||||||
adsLoader = loaderConstructor.newInstance(this, adTagUri);
|
adsLoader = loaderConstructor.newInstance(this, adTagUri);
|
||||||
}
|
}
|
||||||
adsLoader.setPlayer(player);
|
adsLoader.setPlayer(player);
|
||||||
AdsMediaSource.MediaSourceFactory adMediaSourceFactory =
|
MediaSourceFactory adMediaSourceFactory =
|
||||||
new AdsMediaSource.MediaSourceFactory() {
|
new MediaSourceFactory() {
|
||||||
@Override
|
@Override
|
||||||
public MediaSource createMediaSource(Uri uri) {
|
public MediaSource createMediaSource(Uri uri) {
|
||||||
return PlayerActivity.this.buildMediaSource(uri);
|
return PlayerActivity.this.buildMediaSource(uri);
|
||||||
|
|
|
||||||
|
|
@ -48,20 +48,14 @@
|
||||||
-dontnote com.google.android.exoplayer2.source.dash.DashMediaSource$Factory
|
-dontnote com.google.android.exoplayer2.source.dash.DashMediaSource$Factory
|
||||||
-keepclasseswithmembers class com.google.android.exoplayer2.source.dash.DashMediaSource$Factory {
|
-keepclasseswithmembers class com.google.android.exoplayer2.source.dash.DashMediaSource$Factory {
|
||||||
<init>(com.google.android.exoplayer2.upstream.DataSource$Factory);
|
<init>(com.google.android.exoplayer2.upstream.DataSource$Factory);
|
||||||
** setStreamKeys(java.util.List);
|
|
||||||
com.google.android.exoplayer2.source.dash.DashMediaSource createMediaSource(android.net.Uri);
|
|
||||||
}
|
}
|
||||||
-dontnote com.google.android.exoplayer2.source.hls.HlsMediaSource$Factory
|
-dontnote com.google.android.exoplayer2.source.hls.HlsMediaSource$Factory
|
||||||
-keepclasseswithmembers class com.google.android.exoplayer2.source.hls.HlsMediaSource$Factory {
|
-keepclasseswithmembers class com.google.android.exoplayer2.source.hls.HlsMediaSource$Factory {
|
||||||
<init>(com.google.android.exoplayer2.upstream.DataSource$Factory);
|
<init>(com.google.android.exoplayer2.upstream.DataSource$Factory);
|
||||||
** setStreamKeys(java.util.List);
|
|
||||||
com.google.android.exoplayer2.source.hls.HlsMediaSource createMediaSource(android.net.Uri);
|
|
||||||
}
|
}
|
||||||
-dontnote com.google.android.exoplayer2.source.smoothstreaming.SsMediaSource$Factory
|
-dontnote com.google.android.exoplayer2.source.smoothstreaming.SsMediaSource$Factory
|
||||||
-keepclasseswithmembers class com.google.android.exoplayer2.source.smoothstreaming.SsMediaSource$Factory {
|
-keepclasseswithmembers class com.google.android.exoplayer2.source.smoothstreaming.SsMediaSource$Factory {
|
||||||
<init>(com.google.android.exoplayer2.upstream.DataSource$Factory);
|
<init>(com.google.android.exoplayer2.upstream.DataSource$Factory);
|
||||||
** setStreamKeys(java.util.List);
|
|
||||||
com.google.android.exoplayer2.source.smoothstreaming.SsMediaSource createMediaSource(android.net.Uri);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Don't warn about checkerframework
|
# Don't warn about checkerframework
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,7 @@ import com.google.android.exoplayer2.drm.FrameworkMediaCrypto;
|
||||||
import com.google.android.exoplayer2.source.MediaPeriod;
|
import com.google.android.exoplayer2.source.MediaPeriod;
|
||||||
import com.google.android.exoplayer2.source.MediaSource;
|
import com.google.android.exoplayer2.source.MediaSource;
|
||||||
import com.google.android.exoplayer2.source.MediaSource.MediaPeriodId;
|
import com.google.android.exoplayer2.source.MediaSource.MediaPeriodId;
|
||||||
|
import com.google.android.exoplayer2.source.MediaSourceFactory;
|
||||||
import com.google.android.exoplayer2.source.ProgressiveMediaSource;
|
import com.google.android.exoplayer2.source.ProgressiveMediaSource;
|
||||||
import com.google.android.exoplayer2.source.TrackGroup;
|
import com.google.android.exoplayer2.source.TrackGroup;
|
||||||
import com.google.android.exoplayer2.source.TrackGroupArray;
|
import com.google.android.exoplayer2.source.TrackGroupArray;
|
||||||
|
|
@ -51,7 +52,6 @@ import com.google.android.exoplayer2.util.Assertions;
|
||||||
import com.google.android.exoplayer2.util.Util;
|
import com.google.android.exoplayer2.util.Util;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.lang.reflect.Constructor;
|
import java.lang.reflect.Constructor;
|
||||||
import java.lang.reflect.Method;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
@ -107,13 +107,17 @@ public final class DownloadHelper {
|
||||||
void onPrepareError(DownloadHelper helper, IOException e);
|
void onPrepareError(DownloadHelper helper, IOException e);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final MediaSourceFactory DASH_FACTORY =
|
@Nullable
|
||||||
getMediaSourceFactory("com.google.android.exoplayer2.source.dash.DashMediaSource$Factory");
|
private static final Constructor<? extends MediaSourceFactory> DASH_FACTORY_CONSTRUCTOR =
|
||||||
private static final MediaSourceFactory SS_FACTORY =
|
getConstructor("com.google.android.exoplayer2.source.dash.DashMediaSource$Factory");
|
||||||
getMediaSourceFactory(
|
|
||||||
"com.google.android.exoplayer2.source.smoothstreaming.SsMediaSource$Factory");
|
@Nullable
|
||||||
private static final MediaSourceFactory HLS_FACTORY =
|
private static final Constructor<? extends MediaSourceFactory> SS_FACTORY_CONSTRUCTOR =
|
||||||
getMediaSourceFactory("com.google.android.exoplayer2.source.hls.HlsMediaSource$Factory");
|
getConstructor("com.google.android.exoplayer2.source.smoothstreaming.SsMediaSource$Factory");
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
private static final Constructor<? extends MediaSourceFactory> HLS_FACTORY_CONSTRUCTOR =
|
||||||
|
getConstructor("com.google.android.exoplayer2.source.hls.HlsMediaSource$Factory");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a {@link DownloadHelper} for progressive streams.
|
* Creates a {@link DownloadHelper} for progressive streams.
|
||||||
|
|
@ -186,7 +190,8 @@ public final class DownloadHelper {
|
||||||
DownloadRequest.TYPE_DASH,
|
DownloadRequest.TYPE_DASH,
|
||||||
uri,
|
uri,
|
||||||
/* cacheKey= */ null,
|
/* cacheKey= */ null,
|
||||||
DASH_FACTORY.createMediaSource(uri, dataSourceFactory, /* streamKeys= */ null),
|
createMediaSourceInternal(
|
||||||
|
DASH_FACTORY_CONSTRUCTOR, uri, dataSourceFactory, /* streamKeys= */ null),
|
||||||
trackSelectorParameters,
|
trackSelectorParameters,
|
||||||
Util.getRendererCapabilities(renderersFactory, drmSessionManager));
|
Util.getRendererCapabilities(renderersFactory, drmSessionManager));
|
||||||
}
|
}
|
||||||
|
|
@ -235,7 +240,8 @@ public final class DownloadHelper {
|
||||||
DownloadRequest.TYPE_HLS,
|
DownloadRequest.TYPE_HLS,
|
||||||
uri,
|
uri,
|
||||||
/* cacheKey= */ null,
|
/* cacheKey= */ null,
|
||||||
HLS_FACTORY.createMediaSource(uri, dataSourceFactory, /* streamKeys= */ null),
|
createMediaSourceInternal(
|
||||||
|
HLS_FACTORY_CONSTRUCTOR, uri, dataSourceFactory, /* streamKeys= */ null),
|
||||||
trackSelectorParameters,
|
trackSelectorParameters,
|
||||||
Util.getRendererCapabilities(renderersFactory, drmSessionManager));
|
Util.getRendererCapabilities(renderersFactory, drmSessionManager));
|
||||||
}
|
}
|
||||||
|
|
@ -284,7 +290,8 @@ public final class DownloadHelper {
|
||||||
DownloadRequest.TYPE_SS,
|
DownloadRequest.TYPE_SS,
|
||||||
uri,
|
uri,
|
||||||
/* cacheKey= */ null,
|
/* cacheKey= */ null,
|
||||||
SS_FACTORY.createMediaSource(uri, dataSourceFactory, /* streamKeys= */ null),
|
createMediaSourceInternal(
|
||||||
|
SS_FACTORY_CONSTRUCTOR, uri, dataSourceFactory, /* streamKeys= */ null),
|
||||||
trackSelectorParameters,
|
trackSelectorParameters,
|
||||||
Util.getRendererCapabilities(renderersFactory, drmSessionManager));
|
Util.getRendererCapabilities(renderersFactory, drmSessionManager));
|
||||||
}
|
}
|
||||||
|
|
@ -299,16 +306,16 @@ public final class DownloadHelper {
|
||||||
*/
|
*/
|
||||||
public static MediaSource createMediaSource(
|
public static MediaSource createMediaSource(
|
||||||
DownloadRequest downloadRequest, DataSource.Factory dataSourceFactory) {
|
DownloadRequest downloadRequest, DataSource.Factory dataSourceFactory) {
|
||||||
MediaSourceFactory factory;
|
Constructor<? extends MediaSourceFactory> constructor;
|
||||||
switch (downloadRequest.type) {
|
switch (downloadRequest.type) {
|
||||||
case DownloadRequest.TYPE_DASH:
|
case DownloadRequest.TYPE_DASH:
|
||||||
factory = DASH_FACTORY;
|
constructor = DASH_FACTORY_CONSTRUCTOR;
|
||||||
break;
|
break;
|
||||||
case DownloadRequest.TYPE_SS:
|
case DownloadRequest.TYPE_SS:
|
||||||
factory = SS_FACTORY;
|
constructor = SS_FACTORY_CONSTRUCTOR;
|
||||||
break;
|
break;
|
||||||
case DownloadRequest.TYPE_HLS:
|
case DownloadRequest.TYPE_HLS:
|
||||||
factory = HLS_FACTORY;
|
constructor = HLS_FACTORY_CONSTRUCTOR;
|
||||||
break;
|
break;
|
||||||
case DownloadRequest.TYPE_PROGRESSIVE:
|
case DownloadRequest.TYPE_PROGRESSIVE:
|
||||||
return new ProgressiveMediaSource.Factory(dataSourceFactory)
|
return new ProgressiveMediaSource.Factory(dataSourceFactory)
|
||||||
|
|
@ -316,8 +323,8 @@ public final class DownloadHelper {
|
||||||
default:
|
default:
|
||||||
throw new IllegalStateException("Unsupported type: " + downloadRequest.type);
|
throw new IllegalStateException("Unsupported type: " + downloadRequest.type);
|
||||||
}
|
}
|
||||||
return factory.createMediaSource(
|
return createMediaSourceInternal(
|
||||||
downloadRequest.uri, dataSourceFactory, downloadRequest.streamKeys);
|
constructor, downloadRequest.uri, dataSourceFactory, downloadRequest.streamKeys);
|
||||||
}
|
}
|
||||||
|
|
||||||
private final String downloadType;
|
private final String downloadType;
|
||||||
|
|
@ -752,54 +759,39 @@ public final class DownloadHelper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static MediaSourceFactory getMediaSourceFactory(String className) {
|
@Nullable
|
||||||
Constructor<?> constructor = null;
|
private static Constructor<? extends MediaSourceFactory> getConstructor(String className) {
|
||||||
Method setStreamKeysMethod = null;
|
|
||||||
Method createMethod = null;
|
|
||||||
try {
|
try {
|
||||||
// LINT.IfChange
|
// LINT.IfChange
|
||||||
Class<?> factoryClazz = Class.forName(className);
|
Class<? extends MediaSourceFactory> factoryClazz =
|
||||||
constructor = factoryClazz.getConstructor(Factory.class);
|
Class.forName(className).asSubclass(MediaSourceFactory.class);
|
||||||
setStreamKeysMethod = factoryClazz.getMethod("setStreamKeys", List.class);
|
return factoryClazz.getConstructor(Factory.class);
|
||||||
createMethod = factoryClazz.getMethod("createMediaSource", Uri.class);
|
|
||||||
// LINT.ThenChange(../../../../../../../../proguard-rules.txt)
|
// LINT.ThenChange(../../../../../../../../proguard-rules.txt)
|
||||||
} catch (ClassNotFoundException e) {
|
} catch (ClassNotFoundException e) {
|
||||||
// Expected if the app was built without the respective module.
|
// Expected if the app was built without the respective module.
|
||||||
} catch (NoSuchMethodException | SecurityException e) {
|
return null;
|
||||||
|
} catch (NoSuchMethodException e) {
|
||||||
// Something is wrong with the library or the proguard configuration.
|
// Something is wrong with the library or the proguard configuration.
|
||||||
throw new IllegalStateException(e);
|
throw new IllegalStateException(e);
|
||||||
}
|
}
|
||||||
return new MediaSourceFactory(constructor, setStreamKeysMethod, createMethod);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final class MediaSourceFactory {
|
private static MediaSource createMediaSourceInternal(
|
||||||
@Nullable private final Constructor<?> constructor;
|
@Nullable Constructor<? extends MediaSourceFactory> constructor,
|
||||||
@Nullable private final Method setStreamKeysMethod;
|
Uri uri,
|
||||||
@Nullable private final Method createMethod;
|
Factory dataSourceFactory,
|
||||||
|
@Nullable List<StreamKey> streamKeys) {
|
||||||
public MediaSourceFactory(
|
if (constructor == null) {
|
||||||
@Nullable Constructor<?> constructor,
|
throw new IllegalStateException("Module missing to create media source.");
|
||||||
@Nullable Method setStreamKeysMethod,
|
|
||||||
@Nullable Method createMethod) {
|
|
||||||
this.constructor = constructor;
|
|
||||||
this.setStreamKeysMethod = setStreamKeysMethod;
|
|
||||||
this.createMethod = createMethod;
|
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
private MediaSource createMediaSource(
|
MediaSourceFactory factory = constructor.newInstance(dataSourceFactory);
|
||||||
Uri uri, Factory dataSourceFactory, @Nullable List<StreamKey> streamKeys) {
|
if (streamKeys != null) {
|
||||||
if (constructor == null || setStreamKeysMethod == null || createMethod == null) {
|
factory.setStreamKeys(streamKeys);
|
||||||
throw new IllegalStateException("Module missing to create media source.");
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
Object factory = constructor.newInstance(dataSourceFactory);
|
|
||||||
if (streamKeys != null) {
|
|
||||||
setStreamKeysMethod.invoke(factory, streamKeys);
|
|
||||||
}
|
|
||||||
return (MediaSource) Assertions.checkNotNull(createMethod.invoke(factory, uri));
|
|
||||||
} catch (Exception e) {
|
|
||||||
throw new IllegalStateException("Failed to instantiate media source.", e);
|
|
||||||
}
|
}
|
||||||
|
return Assertions.checkNotNull(factory.createMediaSource(uri));
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new IllegalStateException("Failed to instantiate media source.", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,6 @@ import com.google.android.exoplayer2.Timeline;
|
||||||
import com.google.android.exoplayer2.extractor.DefaultExtractorsFactory;
|
import com.google.android.exoplayer2.extractor.DefaultExtractorsFactory;
|
||||||
import com.google.android.exoplayer2.extractor.Extractor;
|
import com.google.android.exoplayer2.extractor.Extractor;
|
||||||
import com.google.android.exoplayer2.extractor.ExtractorsFactory;
|
import com.google.android.exoplayer2.extractor.ExtractorsFactory;
|
||||||
import com.google.android.exoplayer2.source.ads.AdsMediaSource;
|
|
||||||
import com.google.android.exoplayer2.upstream.Allocator;
|
import com.google.android.exoplayer2.upstream.Allocator;
|
||||||
import com.google.android.exoplayer2.upstream.DataSource;
|
import com.google.android.exoplayer2.upstream.DataSource;
|
||||||
import com.google.android.exoplayer2.upstream.DefaultLoadErrorHandlingPolicy;
|
import com.google.android.exoplayer2.upstream.DefaultLoadErrorHandlingPolicy;
|
||||||
|
|
@ -61,7 +60,7 @@ public final class ExtractorMediaSource extends BaseMediaSource
|
||||||
|
|
||||||
/** Use {@link ProgressiveMediaSource.Factory} instead. */
|
/** Use {@link ProgressiveMediaSource.Factory} instead. */
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public static final class Factory implements AdsMediaSource.MediaSourceFactory {
|
public static final class Factory implements MediaSourceFactory {
|
||||||
|
|
||||||
private final DataSource.Factory dataSourceFactory;
|
private final DataSource.Factory dataSourceFactory;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,51 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2019 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package com.google.android.exoplayer2.source;
|
||||||
|
|
||||||
|
import android.net.Uri;
|
||||||
|
import com.google.android.exoplayer2.C;
|
||||||
|
import com.google.android.exoplayer2.offline.StreamKey;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/** Factory for creating {@link MediaSource}s from URIs. */
|
||||||
|
public interface MediaSourceFactory {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets a list of {@link StreamKey StreamKeys} by which the manifest is filtered.
|
||||||
|
*
|
||||||
|
* @param streamKeys A list of {@link StreamKey StreamKeys}.
|
||||||
|
* @return This factory, for convenience.
|
||||||
|
* @throws IllegalStateException If {@link #createMediaSource(Uri)} has already been called.
|
||||||
|
*/
|
||||||
|
default MediaSourceFactory setStreamKeys(List<StreamKey> streamKeys) {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new {@link MediaSource} with the specified {@code uri}.
|
||||||
|
*
|
||||||
|
* @param uri The URI to play.
|
||||||
|
* @return The new {@link MediaSource media source}.
|
||||||
|
*/
|
||||||
|
MediaSource createMediaSource(Uri uri);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the {@link C.ContentType content types} supported by media sources created by this
|
||||||
|
* factory.
|
||||||
|
*/
|
||||||
|
@C.ContentType
|
||||||
|
int[] getSupportedTypes();
|
||||||
|
}
|
||||||
|
|
@ -21,7 +21,6 @@ import com.google.android.exoplayer2.C;
|
||||||
import com.google.android.exoplayer2.extractor.DefaultExtractorsFactory;
|
import com.google.android.exoplayer2.extractor.DefaultExtractorsFactory;
|
||||||
import com.google.android.exoplayer2.extractor.Extractor;
|
import com.google.android.exoplayer2.extractor.Extractor;
|
||||||
import com.google.android.exoplayer2.extractor.ExtractorsFactory;
|
import com.google.android.exoplayer2.extractor.ExtractorsFactory;
|
||||||
import com.google.android.exoplayer2.source.ads.AdsMediaSource;
|
|
||||||
import com.google.android.exoplayer2.upstream.Allocator;
|
import com.google.android.exoplayer2.upstream.Allocator;
|
||||||
import com.google.android.exoplayer2.upstream.DataSource;
|
import com.google.android.exoplayer2.upstream.DataSource;
|
||||||
import com.google.android.exoplayer2.upstream.DefaultLoadErrorHandlingPolicy;
|
import com.google.android.exoplayer2.upstream.DefaultLoadErrorHandlingPolicy;
|
||||||
|
|
@ -45,7 +44,7 @@ public final class ProgressiveMediaSource extends BaseMediaSource
|
||||||
implements ProgressiveMediaPeriod.Listener {
|
implements ProgressiveMediaPeriod.Listener {
|
||||||
|
|
||||||
/** Factory for {@link ProgressiveMediaSource}s. */
|
/** Factory for {@link ProgressiveMediaSource}s. */
|
||||||
public static final class Factory implements AdsMediaSource.MediaSourceFactory {
|
public static final class Factory implements MediaSourceFactory {
|
||||||
|
|
||||||
private final DataSource.Factory dataSourceFactory;
|
private final DataSource.Factory dataSourceFactory;
|
||||||
|
|
||||||
|
|
@ -87,7 +86,7 @@ public final class ProgressiveMediaSource extends BaseMediaSource
|
||||||
* possible formats are known, pass a factory that instantiates extractors for those
|
* possible formats are known, pass a factory that instantiates extractors for those
|
||||||
* formats.
|
* formats.
|
||||||
* @return This factory, for convenience.
|
* @return This factory, for convenience.
|
||||||
* @throws IllegalStateException If one of the {@code create} methods has already been called.
|
* @throws IllegalStateException If {@link #createMediaSource(Uri)} has already been called.
|
||||||
* @deprecated Pass the {@link ExtractorsFactory} via {@link #Factory(DataSource.Factory,
|
* @deprecated Pass the {@link ExtractorsFactory} via {@link #Factory(DataSource.Factory,
|
||||||
* ExtractorsFactory)}. This is necessary so that proguard can treat the default extractors
|
* ExtractorsFactory)}. This is necessary so that proguard can treat the default extractors
|
||||||
* factory as unused.
|
* factory as unused.
|
||||||
|
|
@ -106,7 +105,7 @@ public final class ProgressiveMediaSource extends BaseMediaSource
|
||||||
* @param customCacheKey A custom key that uniquely identifies the original stream. Used for
|
* @param customCacheKey A custom key that uniquely identifies the original stream. Used for
|
||||||
* cache indexing.
|
* cache indexing.
|
||||||
* @return This factory, for convenience.
|
* @return This factory, for convenience.
|
||||||
* @throws IllegalStateException If one of the {@code create} methods has already been called.
|
* @throws IllegalStateException If {@link #createMediaSource(Uri)} has already been called.
|
||||||
*/
|
*/
|
||||||
public Factory setCustomCacheKey(String customCacheKey) {
|
public Factory setCustomCacheKey(String customCacheKey) {
|
||||||
Assertions.checkState(!isCreateCalled);
|
Assertions.checkState(!isCreateCalled);
|
||||||
|
|
@ -121,7 +120,7 @@ public final class ProgressiveMediaSource extends BaseMediaSource
|
||||||
*
|
*
|
||||||
* @param tag A tag for the media source.
|
* @param tag A tag for the media source.
|
||||||
* @return This factory, for convenience.
|
* @return This factory, for convenience.
|
||||||
* @throws IllegalStateException If one of the {@code create} methods has already been called.
|
* @throws IllegalStateException If {@link #createMediaSource(Uri)} has already been called.
|
||||||
*/
|
*/
|
||||||
public Factory setTag(Object tag) {
|
public Factory setTag(Object tag) {
|
||||||
Assertions.checkState(!isCreateCalled);
|
Assertions.checkState(!isCreateCalled);
|
||||||
|
|
@ -135,7 +134,7 @@ public final class ProgressiveMediaSource extends BaseMediaSource
|
||||||
*
|
*
|
||||||
* @param loadErrorHandlingPolicy A {@link LoadErrorHandlingPolicy}.
|
* @param loadErrorHandlingPolicy A {@link LoadErrorHandlingPolicy}.
|
||||||
* @return This factory, for convenience.
|
* @return This factory, for convenience.
|
||||||
* @throws IllegalStateException If one of the {@code create} methods has already been called.
|
* @throws IllegalStateException If {@link #createMediaSource(Uri)} has already been called.
|
||||||
*/
|
*/
|
||||||
public Factory setLoadErrorHandlingPolicy(LoadErrorHandlingPolicy loadErrorHandlingPolicy) {
|
public Factory setLoadErrorHandlingPolicy(LoadErrorHandlingPolicy loadErrorHandlingPolicy) {
|
||||||
Assertions.checkState(!isCreateCalled);
|
Assertions.checkState(!isCreateCalled);
|
||||||
|
|
@ -152,7 +151,7 @@ public final class ProgressiveMediaSource extends BaseMediaSource
|
||||||
* each invocation of {@link
|
* each invocation of {@link
|
||||||
* MediaPeriod.Callback#onContinueLoadingRequested(SequenceableLoader)}.
|
* MediaPeriod.Callback#onContinueLoadingRequested(SequenceableLoader)}.
|
||||||
* @return This factory, for convenience.
|
* @return This factory, for convenience.
|
||||||
* @throws IllegalStateException If one of the {@code create} methods has already been called.
|
* @throws IllegalStateException If {@link #createMediaSource(Uri)} has already been called.
|
||||||
*/
|
*/
|
||||||
public Factory setContinueLoadingCheckIntervalBytes(int continueLoadingCheckIntervalBytes) {
|
public Factory setContinueLoadingCheckIntervalBytes(int continueLoadingCheckIntervalBytes) {
|
||||||
Assertions.checkState(!isCreateCalled);
|
Assertions.checkState(!isCreateCalled);
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@ import com.google.android.exoplayer2.source.MediaSource.MediaPeriodId;
|
||||||
import com.google.android.exoplayer2.source.MediaSourceEventListener;
|
import com.google.android.exoplayer2.source.MediaSourceEventListener;
|
||||||
import com.google.android.exoplayer2.source.MediaSourceEventListener.LoadEventInfo;
|
import com.google.android.exoplayer2.source.MediaSourceEventListener.LoadEventInfo;
|
||||||
import com.google.android.exoplayer2.source.MediaSourceEventListener.MediaLoadData;
|
import com.google.android.exoplayer2.source.MediaSourceEventListener.MediaLoadData;
|
||||||
|
import com.google.android.exoplayer2.source.MediaSourceFactory;
|
||||||
import com.google.android.exoplayer2.source.ProgressiveMediaSource;
|
import com.google.android.exoplayer2.source.ProgressiveMediaSource;
|
||||||
import com.google.android.exoplayer2.upstream.Allocator;
|
import com.google.android.exoplayer2.upstream.Allocator;
|
||||||
import com.google.android.exoplayer2.upstream.DataSource;
|
import com.google.android.exoplayer2.upstream.DataSource;
|
||||||
|
|
@ -54,27 +55,6 @@ import java.util.Map;
|
||||||
*/
|
*/
|
||||||
public final class AdsMediaSource extends CompositeMediaSource<MediaPeriodId> {
|
public final class AdsMediaSource extends CompositeMediaSource<MediaPeriodId> {
|
||||||
|
|
||||||
/** Factory for creating {@link MediaSource}s to play ad media. */
|
|
||||||
public interface MediaSourceFactory {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a new {@link MediaSource} for loading the ad media with the specified {@code uri}.
|
|
||||||
*
|
|
||||||
* @param uri The URI of the media or manifest to play.
|
|
||||||
* @return The new media source.
|
|
||||||
*/
|
|
||||||
MediaSource createMediaSource(Uri uri);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the content types supported by media sources created by this factory. Each element
|
|
||||||
* should be one of {@link C#TYPE_DASH}, {@link C#TYPE_SS}, {@link C#TYPE_HLS} or {@link
|
|
||||||
* C#TYPE_OTHER}.
|
|
||||||
*
|
|
||||||
* @return The content types supported by media sources created by this factory.
|
|
||||||
*/
|
|
||||||
int[] getSupportedTypes();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wrapper for exceptions that occur while loading ads, which are notified via {@link
|
* Wrapper for exceptions that occur while loading ads, which are notified via {@link
|
||||||
* MediaSourceEventListener#onLoadError(int, MediaPeriodId, LoadEventInfo, MediaLoadData,
|
* MediaSourceEventListener#onLoadError(int, MediaPeriodId, LoadEventInfo, MediaLoadData,
|
||||||
|
|
|
||||||
|
|
@ -34,8 +34,8 @@ import com.google.android.exoplayer2.source.MediaPeriod;
|
||||||
import com.google.android.exoplayer2.source.MediaSource;
|
import com.google.android.exoplayer2.source.MediaSource;
|
||||||
import com.google.android.exoplayer2.source.MediaSourceEventListener;
|
import com.google.android.exoplayer2.source.MediaSourceEventListener;
|
||||||
import com.google.android.exoplayer2.source.MediaSourceEventListener.EventDispatcher;
|
import com.google.android.exoplayer2.source.MediaSourceEventListener.EventDispatcher;
|
||||||
|
import com.google.android.exoplayer2.source.MediaSourceFactory;
|
||||||
import com.google.android.exoplayer2.source.SequenceableLoader;
|
import com.google.android.exoplayer2.source.SequenceableLoader;
|
||||||
import com.google.android.exoplayer2.source.ads.AdsMediaSource;
|
|
||||||
import com.google.android.exoplayer2.source.dash.PlayerEmsgHandler.PlayerEmsgCallback;
|
import com.google.android.exoplayer2.source.dash.PlayerEmsgHandler.PlayerEmsgCallback;
|
||||||
import com.google.android.exoplayer2.source.dash.manifest.AdaptationSet;
|
import com.google.android.exoplayer2.source.dash.manifest.AdaptationSet;
|
||||||
import com.google.android.exoplayer2.source.dash.manifest.DashManifest;
|
import com.google.android.exoplayer2.source.dash.manifest.DashManifest;
|
||||||
|
|
@ -74,7 +74,7 @@ public final class DashMediaSource extends BaseMediaSource {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Factory for {@link DashMediaSource}s. */
|
/** Factory for {@link DashMediaSource}s. */
|
||||||
public static final class Factory implements AdsMediaSource.MediaSourceFactory {
|
public static final class Factory implements MediaSourceFactory {
|
||||||
|
|
||||||
private final DashChunkSource.Factory chunkSourceFactory;
|
private final DashChunkSource.Factory chunkSourceFactory;
|
||||||
@Nullable private final DataSource.Factory manifestDataSourceFactory;
|
@Nullable private final DataSource.Factory manifestDataSourceFactory;
|
||||||
|
|
@ -213,19 +213,6 @@ public final class DashMediaSource extends BaseMediaSource {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets a list of {@link StreamKey stream keys} by which the manifest is filtered.
|
|
||||||
*
|
|
||||||
* @param streamKeys A list of {@link StreamKey stream keys}.
|
|
||||||
* @return This factory, for convenience.
|
|
||||||
* @throws IllegalStateException If one of the {@code create} methods has already been called.
|
|
||||||
*/
|
|
||||||
public Factory setStreamKeys(List<StreamKey> streamKeys) {
|
|
||||||
Assertions.checkState(!isCreateCalled);
|
|
||||||
this.streamKeys = streamKeys;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the factory to create composite {@link SequenceableLoader}s for when this media source
|
* Sets the factory to create composite {@link SequenceableLoader}s for when this media source
|
||||||
* loads data from multiple streams (video, audio etc...). The default is an instance of {@link
|
* loads data from multiple streams (video, audio etc...). The default is an instance of {@link
|
||||||
|
|
@ -288,6 +275,22 @@ public final class DashMediaSource extends BaseMediaSource {
|
||||||
return mediaSource;
|
return mediaSource;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated Use {@link #createMediaSource(Uri)} and {@link #addEventListener(Handler,
|
||||||
|
* MediaSourceEventListener)} instead.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public DashMediaSource createMediaSource(
|
||||||
|
Uri manifestUri,
|
||||||
|
@Nullable Handler eventHandler,
|
||||||
|
@Nullable MediaSourceEventListener eventListener) {
|
||||||
|
DashMediaSource mediaSource = createMediaSource(manifestUri);
|
||||||
|
if (eventHandler != null && eventListener != null) {
|
||||||
|
mediaSource.addEventListener(eventHandler, eventListener);
|
||||||
|
}
|
||||||
|
return mediaSource;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a new {@link DashMediaSource} using the current parameters.
|
* Returns a new {@link DashMediaSource} using the current parameters.
|
||||||
*
|
*
|
||||||
|
|
@ -316,20 +319,11 @@ public final class DashMediaSource extends BaseMediaSource {
|
||||||
tag);
|
tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* @deprecated Use {@link #createMediaSource(Uri)} and {@link #addEventListener(Handler,
|
public Factory setStreamKeys(List<StreamKey> streamKeys) {
|
||||||
* MediaSourceEventListener)} instead.
|
Assertions.checkState(!isCreateCalled);
|
||||||
*/
|
this.streamKeys = streamKeys;
|
||||||
@Deprecated
|
return this;
|
||||||
public DashMediaSource createMediaSource(
|
|
||||||
Uri manifestUri,
|
|
||||||
@Nullable Handler eventHandler,
|
|
||||||
@Nullable MediaSourceEventListener eventListener) {
|
|
||||||
DashMediaSource mediaSource = createMediaSource(manifestUri);
|
|
||||||
if (eventHandler != null && eventListener != null) {
|
|
||||||
mediaSource.addEventListener(eventHandler, eventListener);
|
|
||||||
}
|
|
||||||
return mediaSource;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -29,9 +29,9 @@ import com.google.android.exoplayer2.source.MediaPeriod;
|
||||||
import com.google.android.exoplayer2.source.MediaSource;
|
import com.google.android.exoplayer2.source.MediaSource;
|
||||||
import com.google.android.exoplayer2.source.MediaSourceEventListener;
|
import com.google.android.exoplayer2.source.MediaSourceEventListener;
|
||||||
import com.google.android.exoplayer2.source.MediaSourceEventListener.EventDispatcher;
|
import com.google.android.exoplayer2.source.MediaSourceEventListener.EventDispatcher;
|
||||||
|
import com.google.android.exoplayer2.source.MediaSourceFactory;
|
||||||
import com.google.android.exoplayer2.source.SequenceableLoader;
|
import com.google.android.exoplayer2.source.SequenceableLoader;
|
||||||
import com.google.android.exoplayer2.source.SinglePeriodTimeline;
|
import com.google.android.exoplayer2.source.SinglePeriodTimeline;
|
||||||
import com.google.android.exoplayer2.source.ads.AdsMediaSource;
|
|
||||||
import com.google.android.exoplayer2.source.hls.playlist.DefaultHlsPlaylistParserFactory;
|
import com.google.android.exoplayer2.source.hls.playlist.DefaultHlsPlaylistParserFactory;
|
||||||
import com.google.android.exoplayer2.source.hls.playlist.DefaultHlsPlaylistTracker;
|
import com.google.android.exoplayer2.source.hls.playlist.DefaultHlsPlaylistTracker;
|
||||||
import com.google.android.exoplayer2.source.hls.playlist.FilteringHlsPlaylistParserFactory;
|
import com.google.android.exoplayer2.source.hls.playlist.FilteringHlsPlaylistParserFactory;
|
||||||
|
|
@ -56,7 +56,7 @@ public final class HlsMediaSource extends BaseMediaSource
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Factory for {@link HlsMediaSource}s. */
|
/** Factory for {@link HlsMediaSource}s. */
|
||||||
public static final class Factory implements AdsMediaSource.MediaSourceFactory {
|
public static final class Factory implements MediaSourceFactory {
|
||||||
|
|
||||||
private final HlsDataSourceFactory hlsDataSourceFactory;
|
private final HlsDataSourceFactory hlsDataSourceFactory;
|
||||||
|
|
||||||
|
|
@ -177,19 +177,6 @@ public final class HlsMediaSource extends BaseMediaSource
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets a list of {@link StreamKey stream keys} by which the playlists are filtered.
|
|
||||||
*
|
|
||||||
* @param streamKeys A list of {@link StreamKey stream keys}.
|
|
||||||
* @return This factory, for convenience.
|
|
||||||
* @throws IllegalStateException If one of the {@code create} methods has already been called.
|
|
||||||
*/
|
|
||||||
public Factory setStreamKeys(List<StreamKey> streamKeys) {
|
|
||||||
Assertions.checkState(!isCreateCalled);
|
|
||||||
this.streamKeys = streamKeys;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the {@link HlsPlaylistTracker} factory. The default value is {@link
|
* Sets the {@link HlsPlaylistTracker} factory. The default value is {@link
|
||||||
* DefaultHlsPlaylistTracker#FACTORY}.
|
* DefaultHlsPlaylistTracker#FACTORY}.
|
||||||
|
|
@ -251,6 +238,22 @@ public final class HlsMediaSource extends BaseMediaSource
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated Use {@link #createMediaSource(Uri)} and {@link #addEventListener(Handler,
|
||||||
|
* MediaSourceEventListener)} instead.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public HlsMediaSource createMediaSource(
|
||||||
|
Uri playlistUri,
|
||||||
|
@Nullable Handler eventHandler,
|
||||||
|
@Nullable MediaSourceEventListener eventListener) {
|
||||||
|
HlsMediaSource mediaSource = createMediaSource(playlistUri);
|
||||||
|
if (eventHandler != null && eventListener != null) {
|
||||||
|
mediaSource.addEventListener(eventHandler, eventListener);
|
||||||
|
}
|
||||||
|
return mediaSource;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a new {@link HlsMediaSource} using the current parameters.
|
* Returns a new {@link HlsMediaSource} using the current parameters.
|
||||||
*
|
*
|
||||||
|
|
@ -276,20 +279,11 @@ public final class HlsMediaSource extends BaseMediaSource
|
||||||
tag);
|
tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* @deprecated Use {@link #createMediaSource(Uri)} and {@link #addEventListener(Handler,
|
public Factory setStreamKeys(List<StreamKey> streamKeys) {
|
||||||
* MediaSourceEventListener)} instead.
|
Assertions.checkState(!isCreateCalled);
|
||||||
*/
|
this.streamKeys = streamKeys;
|
||||||
@Deprecated
|
return this;
|
||||||
public HlsMediaSource createMediaSource(
|
|
||||||
Uri playlistUri,
|
|
||||||
@Nullable Handler eventHandler,
|
|
||||||
@Nullable MediaSourceEventListener eventListener) {
|
|
||||||
HlsMediaSource mediaSource = createMediaSource(playlistUri);
|
|
||||||
if (eventHandler != null && eventListener != null) {
|
|
||||||
mediaSource.addEventListener(eventHandler, eventListener);
|
|
||||||
}
|
|
||||||
return mediaSource;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -31,9 +31,9 @@ import com.google.android.exoplayer2.source.MediaPeriod;
|
||||||
import com.google.android.exoplayer2.source.MediaSource;
|
import com.google.android.exoplayer2.source.MediaSource;
|
||||||
import com.google.android.exoplayer2.source.MediaSourceEventListener;
|
import com.google.android.exoplayer2.source.MediaSourceEventListener;
|
||||||
import com.google.android.exoplayer2.source.MediaSourceEventListener.EventDispatcher;
|
import com.google.android.exoplayer2.source.MediaSourceEventListener.EventDispatcher;
|
||||||
|
import com.google.android.exoplayer2.source.MediaSourceFactory;
|
||||||
import com.google.android.exoplayer2.source.SequenceableLoader;
|
import com.google.android.exoplayer2.source.SequenceableLoader;
|
||||||
import com.google.android.exoplayer2.source.SinglePeriodTimeline;
|
import com.google.android.exoplayer2.source.SinglePeriodTimeline;
|
||||||
import com.google.android.exoplayer2.source.ads.AdsMediaSource;
|
|
||||||
import com.google.android.exoplayer2.source.smoothstreaming.manifest.SsManifest;
|
import com.google.android.exoplayer2.source.smoothstreaming.manifest.SsManifest;
|
||||||
import com.google.android.exoplayer2.source.smoothstreaming.manifest.SsManifest.StreamElement;
|
import com.google.android.exoplayer2.source.smoothstreaming.manifest.SsManifest.StreamElement;
|
||||||
import com.google.android.exoplayer2.source.smoothstreaming.manifest.SsManifestParser;
|
import com.google.android.exoplayer2.source.smoothstreaming.manifest.SsManifestParser;
|
||||||
|
|
@ -61,7 +61,7 @@ public final class SsMediaSource extends BaseMediaSource
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Factory for {@link SsMediaSource}. */
|
/** Factory for {@link SsMediaSource}. */
|
||||||
public static final class Factory implements AdsMediaSource.MediaSourceFactory {
|
public static final class Factory implements MediaSourceFactory {
|
||||||
|
|
||||||
private final SsChunkSource.Factory chunkSourceFactory;
|
private final SsChunkSource.Factory chunkSourceFactory;
|
||||||
@Nullable private final DataSource.Factory manifestDataSourceFactory;
|
@Nullable private final DataSource.Factory manifestDataSourceFactory;
|
||||||
|
|
@ -180,19 +180,6 @@ public final class SsMediaSource extends BaseMediaSource
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets a list of {@link StreamKey stream keys} by which the manifest is filtered.
|
|
||||||
*
|
|
||||||
* @param streamKeys A list of {@link StreamKey stream keys}.
|
|
||||||
* @return This factory, for convenience.
|
|
||||||
* @throws IllegalStateException If one of the {@code create} methods has already been called.
|
|
||||||
*/
|
|
||||||
public Factory setStreamKeys(List<StreamKey> streamKeys) {
|
|
||||||
Assertions.checkState(!isCreateCalled);
|
|
||||||
this.streamKeys = streamKeys;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the factory to create composite {@link SequenceableLoader}s for when this media source
|
* Sets the factory to create composite {@link SequenceableLoader}s for when this media source
|
||||||
* loads data from multiple streams (video, audio etc.). The default is an instance of {@link
|
* loads data from multiple streams (video, audio etc.). The default is an instance of {@link
|
||||||
|
|
@ -254,6 +241,22 @@ public final class SsMediaSource extends BaseMediaSource
|
||||||
return mediaSource;
|
return mediaSource;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated Use {@link #createMediaSource(Uri)} and {@link #addEventListener(Handler,
|
||||||
|
* MediaSourceEventListener)} instead.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public SsMediaSource createMediaSource(
|
||||||
|
Uri manifestUri,
|
||||||
|
@Nullable Handler eventHandler,
|
||||||
|
@Nullable MediaSourceEventListener eventListener) {
|
||||||
|
SsMediaSource mediaSource = createMediaSource(manifestUri);
|
||||||
|
if (eventHandler != null && eventListener != null) {
|
||||||
|
mediaSource.addEventListener(eventHandler, eventListener);
|
||||||
|
}
|
||||||
|
return mediaSource;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a new {@link SsMediaSource} using the current parameters.
|
* Returns a new {@link SsMediaSource} using the current parameters.
|
||||||
*
|
*
|
||||||
|
|
@ -281,20 +284,11 @@ public final class SsMediaSource extends BaseMediaSource
|
||||||
tag);
|
tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* @deprecated Use {@link #createMediaSource(Uri)} and {@link #addEventListener(Handler,
|
public Factory setStreamKeys(List<StreamKey> streamKeys) {
|
||||||
* MediaSourceEventListener)} instead.
|
Assertions.checkState(!isCreateCalled);
|
||||||
*/
|
this.streamKeys = streamKeys;
|
||||||
@Deprecated
|
return this;
|
||||||
public SsMediaSource createMediaSource(
|
|
||||||
Uri manifestUri,
|
|
||||||
@Nullable Handler eventHandler,
|
|
||||||
@Nullable MediaSourceEventListener eventListener) {
|
|
||||||
SsMediaSource mediaSource = createMediaSource(manifestUri);
|
|
||||||
if (eventHandler != null && eventListener != null) {
|
|
||||||
mediaSource.addEventListener(eventHandler, eventListener);
|
|
||||||
}
|
|
||||||
return mediaSource;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue