本文整理汇总了Java中com.google.android.exoplayer.upstream.UriDataSource类的典型用法代码示例。如果您正苦于以下问题:Java UriDataSource类的具体用法?Java UriDataSource怎么用?Java UriDataSource使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
UriDataSource类属于com.google.android.exoplayer.upstream包,在下文中一共展示了UriDataSource类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onManifest
import com.google.android.exoplayer.upstream.UriDataSource; //导入依赖的package包/类
@Override
public void onManifest(String contentId, HlsPlaylist manifest) {
DefaultBandwidthMeter bandwidthMeter = new DefaultBandwidthMeter();
DataSource dataSource = new UriDataSource(userAgent, bandwidthMeter);
HlsChunkSource chunkSource = new HlsChunkSource(dataSource, url, manifest, bandwidthMeter, null,
HlsChunkSource.ADAPTIVE_MODE_SPLICE);
HlsSampleSource sampleSource = new HlsSampleSource(chunkSource, true, 3);
MediaCodecVideoTrackRenderer videoRenderer = new MediaCodecVideoTrackRenderer(sampleSource,
MediaCodec.VIDEO_SCALING_MODE_SCALE_TO_FIT, 5000, player.getMainHandler(), player, 50);
MediaCodecAudioTrackRenderer audioRenderer = new MediaCodecAudioTrackRenderer(sampleSource);
MetadataTrackRenderer<Map<String, Object>> id3Renderer =
new MetadataTrackRenderer<Map<String, Object>>(sampleSource, new Id3Parser(),
player.getId3MetadataRenderer(), player.getMainHandler().getLooper());
Eia608TrackRenderer closedCaptionRenderer = new Eia608TrackRenderer(sampleSource, player,
player.getMainHandler().getLooper());
TrackRenderer[] renderers = new TrackRenderer[DemoPlayer.RENDERER_COUNT];
renderers[DemoPlayer.TYPE_VIDEO] = videoRenderer;
renderers[DemoPlayer.TYPE_AUDIO] = audioRenderer;
renderers[DemoPlayer.TYPE_TIMED_METADATA] = id3Renderer;
renderers[DemoPlayer.TYPE_TEXT] = closedCaptionRenderer;
callback.onRenderers(null, null, renderers);
}
示例2: ManifestFetcher
import com.google.android.exoplayer.upstream.UriDataSource; //导入依赖的package包/类
/**
* @param manifestUri The manifest location.
* @param uriDataSource The {@link UriDataSource} to use when loading the manifest.
* @param parser A parser to parse the loaded manifest data.
* @param eventHandler A handler to use when delivering events to {@code eventListener}. May be
* null if delivery of events is not required.
* @param eventListener A listener of events. May be null if delivery of events is not required.
*/
public ManifestFetcher(String manifestUri, UriDataSource uriDataSource,
UriLoadable.Parser<T> parser, Handler eventHandler, EventListener eventListener) {
this.parser = parser;
this.manifestUri = manifestUri;
this.uriDataSource = uriDataSource;
this.eventHandler = eventHandler;
this.eventListener = eventListener;
}
示例3: UtcTimingElementResolver
import com.google.android.exoplayer.upstream.UriDataSource; //导入依赖的package包/类
private UtcTimingElementResolver(UriDataSource uriDataSource, UtcTimingElement timingElement,
long timingElementElapsedRealtime, UtcTimingCallback callback) {
this.uriDataSource = uriDataSource;
this.timingElement = Assertions.checkNotNull(timingElement);
this.timingElementElapsedRealtime = timingElementElapsedRealtime;
this.callback = Assertions.checkNotNull(callback);
}
示例4: createDataSource
import com.google.android.exoplayer.upstream.UriDataSource; //导入依赖的package包/类
private static UriDataSource createDataSource(Context context, String userAgent,
TransferListener transferListener) {
return new DefaultUriDataSource(
context,
transferListener,
new OkHttpDataSource(userAgent, null, transferListener)
);
}
示例5: createManifestDataSource
import com.google.android.exoplayer.upstream.UriDataSource; //导入依赖的package包/类
protected UriDataSource createManifestDataSource(Context context, String userAgent) {
return new DefaultUriDataSource(context, userAgent);
}
示例6: createManifestDataSource
import com.google.android.exoplayer.upstream.UriDataSource; //导入依赖的package包/类
@SuppressWarnings("UnusedParameters") // Context kept for consistency with the HLS and Dash builders
protected UriDataSource createManifestDataSource(Context context, String userAgent) {
return new DefaultHttpDataSource(userAgent, null);
}
示例7: onManifest
import com.google.android.exoplayer.upstream.UriDataSource; //导入依赖的package包/类
@Override
public void onManifest(String contentId, SmoothStreamingManifest manifest) {
Handler mainHandler = playerActivity.getMainHandler();
LoadControl loadControl = new DefaultLoadControl(new BufferPool(BUFFER_SEGMENT_SIZE));
DefaultBandwidthMeter bandwidthMeter = new DefaultBandwidthMeter();
// Obtain stream elements for playback.
int maxDecodableFrameSize = MediaCodecUtil.maxH264DecodableFrameSize();
int audioStreamElementIndex = -1;
int videoStreamElementIndex = -1;
ArrayList<Integer> videoTrackIndexList = new ArrayList<Integer>();
for (int i = 0; i < manifest.streamElements.length; i++) {
if (audioStreamElementIndex == -1
&& manifest.streamElements[i].type == StreamElement.TYPE_AUDIO) {
audioStreamElementIndex = i;
} else if (videoStreamElementIndex == -1
&& manifest.streamElements[i].type == StreamElement.TYPE_VIDEO) {
videoStreamElementIndex = i;
StreamElement streamElement = manifest.streamElements[i];
for (int j = 0; j < streamElement.tracks.length; j++) {
TrackElement trackElement = streamElement.tracks[j];
if (trackElement.maxWidth * trackElement.maxHeight <= maxDecodableFrameSize) {
videoTrackIndexList.add(j);
} else {
// The device isn't capable of playing this stream.
}
}
}
}
int[] videoTrackIndices = Util.toArray(videoTrackIndexList);
// Build the video renderer.
DataSource videoDataSource = new UriDataSource(userAgent, bandwidthMeter);
ChunkSource videoChunkSource = new SmoothStreamingChunkSource(manifestFetcher,
videoStreamElementIndex, videoTrackIndices, videoDataSource,
new AdaptiveEvaluator(bandwidthMeter), LIVE_EDGE_LATENCY_MS);
ChunkSampleSource videoSampleSource = new ChunkSampleSource(videoChunkSource, loadControl,
VIDEO_BUFFER_SEGMENTS * BUFFER_SEGMENT_SIZE, true);
MediaCodecVideoTrackRenderer videoRenderer = new MediaCodecVideoTrackRenderer(videoSampleSource,
MediaCodec.VIDEO_SCALING_MODE_SCALE_TO_FIT, 0, mainHandler, playerActivity, 50);
// Build the audio renderer.
DataSource audioDataSource = new UriDataSource(userAgent, bandwidthMeter);
ChunkSource audioChunkSource = new SmoothStreamingChunkSource(manifestFetcher,
audioStreamElementIndex, new int[] {0}, audioDataSource,
new FormatEvaluator.FixedEvaluator(), LIVE_EDGE_LATENCY_MS);
SampleSource audioSampleSource = new ChunkSampleSource(audioChunkSource, loadControl,
AUDIO_BUFFER_SEGMENTS * BUFFER_SEGMENT_SIZE, true);
MediaCodecAudioTrackRenderer audioRenderer = new MediaCodecAudioTrackRenderer(
audioSampleSource);
callback.onRenderers(videoRenderer, audioRenderer);
}
示例8: resolveTimingElement
import com.google.android.exoplayer.upstream.UriDataSource; //导入依赖的package包/类
/**
* Resolves a {@link UtcTimingElement}.
*
* @param uriDataSource A source to use should loading from a URI be necessary.
* @param timingElement The element to resolve.
* @param timingElementElapsedRealtime The {@link SystemClock#elapsedRealtime()} timestamp at
* which the element was obtained. Used if the element contains a timestamp directly.
* @param callback The callback to invoke on resolution or failure.
*/
public static void resolveTimingElement(UriDataSource uriDataSource,
UtcTimingElement timingElement, long timingElementElapsedRealtime,
UtcTimingCallback callback) {
UtcTimingElementResolver resolver = new UtcTimingElementResolver(uriDataSource, timingElement,
timingElementElapsedRealtime, callback);
resolver.resolve();
}