本文整理汇总了Java中com.google.android.exoplayer.upstream.FileDataSource类的典型用法代码示例。如果您正苦于以下问题:Java FileDataSource类的具体用法?Java FileDataSource怎么用?Java FileDataSource使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FileDataSource类属于com.google.android.exoplayer.upstream包,在下文中一共展示了FileDataSource类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buildRenderers
import com.google.android.exoplayer.upstream.FileDataSource; //导入依赖的package包/类
@Override
public void buildRenderers(ExoPlayerHelper player) {
Allocator allocator = new DefaultAllocator(BUFFER_SEGMENT_SIZE);
// Build the video and audio renderers.
Extractor webmExtractor = new WebmExtractor();
Extractor mp4Extractor = new Mp4Extractor();
DataSource dataSource = new FileDataSource();
ExtractorSampleSource sampleSource = new ExtractorSampleSource(uri, dataSource, allocator,
BUFFER_SEGMENT_COUNT * BUFFER_SEGMENT_SIZE, webmExtractor, mp4Extractor);
MediaCodecVideoTrackRenderer videoRenderer = new MediaCodecVideoTrackRenderer(context,
sampleSource, MediaCodecSelector.DEFAULT, MediaCodec.VIDEO_SCALING_MODE_SCALE_TO_FIT, 5000, player.getMainHandler(),
player, 50);
MediaCodecAudioTrackRenderer audioRenderer = new MediaCodecAudioTrackRenderer(sampleSource, MediaCodecSelector.DEFAULT,
null, true, player.getMainHandler(), player);
TrackRenderer textRenderer = new TextTrackRenderer(sampleSource, player,
player.getMainHandler().getLooper());
// Invoke the callback.
TrackRenderer[] renderers = new TrackRenderer[ExoPlayerHelper.RENDERER_COUNT];
renderers[ExoPlayerHelper.TYPE_VIDEO] = videoRenderer;
renderers[ExoPlayerHelper.TYPE_AUDIO] = audioRenderer;
renderers[ExoPlayerHelper.TYPE_TEXT] = textRenderer;
player.onRenderers(renderers, null);
}
示例2: loadDrmInitData
import com.google.android.exoplayer.upstream.FileDataSource; //导入依赖的package包/类
private void loadDrmInitData(Representation representation) throws IOException {
Uri initFile = representation.getInitializationUri().getUri();
FileDataSource initChunkSource = new FileDataSource();
DataSpec initDataSpec = new DataSpec(initFile);
int trigger = 2;
ChunkExtractorWrapper extractorWrapper = new ChunkExtractorWrapper(new FragmentedMp4Extractor());
InitializationChunk chunk = new InitializationChunk(initChunkSource, initDataSpec, trigger, format, extractorWrapper);
try {
chunk.load();
} catch (InterruptedException e) {
Log.d(TAG, "Interrupted!", e);
}
if (!chunk.isLoadCanceled()) {
drmInitData = chunk.getDrmInitData();
}
if (drmInitData != null) {
DrmInitData.SchemeInitData schemeInitData = OfflineDrmManager.getWidevineInitData(drmInitData);
if (schemeInitData != null) {
widevineInitData = schemeInitData.data;
}
}
}
示例3: CacheDataSource
import com.google.android.exoplayer.upstream.FileDataSource; //导入依赖的package包/类
/**
* Constructs an instance with default {@link DataSource} and {@link DataSink} instances for
* reading and writing the cache. The sink is configured to fragment data such that no single
* cache file is greater than maxCacheFileSize bytes.
*/
public CacheDataSource(Cache cache, DataSource upstream, boolean blockOnCache,
boolean ignoreCacheOnError, long maxCacheFileSize) {
this(cache, upstream, new FileDataSource(), new CacheDataSink(cache, maxCacheFileSize),
blockOnCache, ignoreCacheOnError, null);
}