카테고리 없음
ExoPlayer build & streaming media source 생성
반응형
1. build
SimpleExoPlayer builder
SimpleExoPlayer
Builder
new DefaultRenderersFactory(context)
new DefaultTrackSelector(context),
new DefaultMediaSourceFactory(context, extractorsFactory),
new DefaultLoadControl(),
DefaultBandwidthMeter.getSingletonInstance(context),
new AnalyticsCollector(Clock.DEFAULT));
new ExoPlayerImpl(
renderers,
builder.trackSelector,
builder.mediaSourceFactory,
builder.loadControl,
builder.bandwidthMeter,
analyticsCollector,
builder.useLazyPreparation,
builder.seekParameters,
builder.seekBackIncrementMs,
builder.seekForwardIncrementMs,
builder.livePlaybackSpeedControl,
builder.releaseTimeoutMs,
builder.pauseAtEndOfMediaItems,
builder.clock,
builder.looper,
ExoPlayerImpl builder
internalPlayer =
new ExoPlayerImplInternal(
renderers,
trackSelector,
emptyTrackSelectorResult,
loadControl,
bandwidthMeter,
repeatMode,
shuffleModeEnabled,
analyticsCollector,
seekParameters,
livePlaybackSpeedControl,
releaseTimeoutMs,
pauseAtEndOfMediaItems,
applicationLooper,
clock,
playbackInfoUpdateListener);
2. Streaming media source
HLS
val factory = DefaultHttpDataSourceFactory(userAgent)
val hlsMediaSrc = HlsMediaSource.Factory(factory).createMediaSource(mediaItem)
DASH
val factory = DefaultHttpDataSourceFactory(userAgent)
val dashMediaSrc = DashMediaSource.Factory(factory).createMediaSource(mediaItem)
HLS data source 생성
DefaultHlsDataSourceFactory(dataSourceFactory)
public HlsMediaSource createMediaSource(Uri uri) {
return createMediaSource(
new MediaItem.Builder().setUri(uri).setMimeType(MimeTypes.APPLICATION_M3U8).build());
}
public HlsMediaSource createMediaSource(MediaItem mediaItem) {
checkNotNull(mediaItem.playbackProperties);
HlsPlaylistParserFactory playlistParserFactory = this.playlistParserFactory;
List<StreamKey> streamKeys =
mediaItem.playbackProperties.streamKeys.isEmpty()
? this.streamKeys
: mediaItem.playbackProperties.streamKeys;
if (!streamKeys.isEmpty()) {
playlistParserFactory =
new FilteringHlsPlaylistParserFactory(playlistParserFactory, streamKeys);
}
boolean needsTag = mediaItem.playbackProperties.tag == null && tag != null;
boolean needsStreamKeys =
mediaItem.playbackProperties.streamKeys.isEmpty() && !streamKeys.isEmpty();
if (needsTag && needsStreamKeys) {
mediaItem = mediaItem.buildUpon().setTag(tag).setStreamKeys(streamKeys).build();
} else if (needsTag) {
mediaItem = mediaItem.buildUpon().setTag(tag).build();
} else if (needsStreamKeys) {
mediaItem = mediaItem.buildUpon().setStreamKeys(streamKeys).build();
}
return new HlsMediaSource(
mediaItem,
hlsDataSourceFactory, <---
extractorFactory,
compositeSequenceableLoaderFactory,
drmSessionManagerProvider.get(mediaItem),
loadErrorHandlingPolicy,
playlistTrackerFactory.createTracker(
hlsDataSourceFactory, loadErrorHandlingPolicy, playlistParserFactory),
elapsedRealTimeOffsetMs,
allowChunklessPreparation,
metadataType,
useSessionKeys);
}
반응형
댓글