本文整理汇总了Java中com.google.android.exoplayer2.source.ConcatenatingMediaSource类的典型用法代码示例。如果您正苦于以下问题:Java ConcatenatingMediaSource类的具体用法?Java ConcatenatingMediaSource怎么用?Java ConcatenatingMediaSource使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ConcatenatingMediaSource类属于com.google.android.exoplayer2.source包,在下文中一共展示了ConcatenatingMediaSource类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initializePlayer
import com.google.android.exoplayer2.source.ConcatenatingMediaSource; //导入依赖的package包/类
private void initializePlayer() {
simpleExoPlayerView.requestFocus();
TrackSelection.Factory videoTrackSelectionFactory =
new AdaptiveTrackSelection.Factory(bandwidthMeter);
trackSelector = new DefaultTrackSelector(videoTrackSelectionFactory);
player = ExoPlayerFactory.newSimpleInstance(this, trackSelector);
simpleExoPlayerView.setPlayer(player);
MediaSource[] mediaSources = new MediaSource[videos.size()];
for (int i = 0; i < videos.size(); i++) {
mediaSources[i] = buildMediaSource(Uri.parse(videos.get(i).videoUrl));
}
MediaSource mediaSource = mediaSources.length == 1 ? mediaSources[0]
: new ConcatenatingMediaSource(mediaSources);
player.prepare(mediaSource);
}
示例2: testShuffleModeEnabledChanges
import com.google.android.exoplayer2.source.ConcatenatingMediaSource; //导入依赖的package包/类
public void testShuffleModeEnabledChanges() throws Exception {
Timeline fakeTimeline = new FakeTimeline(/* windowCount= */ 1);
MediaSource[] fakeMediaSources = {
new FakeMediaSource(fakeTimeline, null, Builder.VIDEO_FORMAT),
new FakeMediaSource(fakeTimeline, null, Builder.VIDEO_FORMAT),
new FakeMediaSource(fakeTimeline, null, Builder.VIDEO_FORMAT)
};
ConcatenatingMediaSource mediaSource = new ConcatenatingMediaSource(false,
new FakeShuffleOrder(3), fakeMediaSources);
FakeRenderer renderer = new FakeRenderer(Builder.VIDEO_FORMAT);
ActionSchedule actionSchedule = new ActionSchedule.Builder("testShuffleModeEnabled")
.setRepeatMode(Player.REPEAT_MODE_ALL).waitForPositionDiscontinuity() // 0 -> 1
.setShuffleModeEnabled(true).waitForPositionDiscontinuity() // 1 -> 0
.waitForPositionDiscontinuity().waitForPositionDiscontinuity() // 0 -> 2 -> 1
.setShuffleModeEnabled(false).setRepeatMode(Player.REPEAT_MODE_OFF) // 1 -> 2 -> end
.build();
ExoPlayerTestRunner testRunner = new ExoPlayerTestRunner.Builder()
.setMediaSource(mediaSource).setRenderers(renderer).setActionSchedule(actionSchedule)
.build().start().blockUntilEnded(TIMEOUT_MS);
testRunner.assertPlayedPeriodIndices(0, 1, 0, 2, 1, 2);
assertTrue(renderer.isEnded);
}
示例3: setMediaUri
import com.google.android.exoplayer2.source.ConcatenatingMediaSource; //导入依赖的package包/类
/****
* 初始化
*
* @param uris 视频的地址列表
*/
public void setMediaUri(@NonNull Uri... uris) {
MediaSource[] firstSources = new MediaSource[uris.length];
int i = 0;
for (Uri item : uris) {
firstSources[i] = initMediaSource(item);
i++;
}
mediaSource = new ConcatenatingMediaSource(firstSources);
}
示例4: CreateListSource
import com.google.android.exoplayer2.source.ConcatenatingMediaSource; //导入依赖的package包/类
/**
* Concatenates multiple sources.
*/
public Object CreateListSource (List Sources) {
MediaSource[] sources = new MediaSource[Sources.getSize()];
for (int i = 0;i < Sources.getSize();i++)
sources[i] = (MediaSource)Sources.Get(i);
return new ConcatenatingMediaSource(sources);
}
示例5: buildRepeatOneMediaSource
import com.google.android.exoplayer2.source.ConcatenatingMediaSource; //导入依赖的package包/类
private MediaSource buildRepeatOneMediaSource(DataSource.Factory srcFactory,
ExtractorsFactory extFactory) {
if (mQueue.isEmpty()) {
// We need to return an empty MediaSource (can't be null), so return a
// ConcatenatingMediaSource with nothing to concatenate
return new ConcatenatingMediaSource();
}
Uri uri = mQueue.get(mQueueIndex).getLocation();
MediaSource source = new ExtractorMediaSource(uri, srcFactory, extFactory, null, null);
return new LoopingMediaSource(source);
}
示例6: buildNoRepeatMediaSource
import com.google.android.exoplayer2.source.ConcatenatingMediaSource; //导入依赖的package包/类
private MediaSource buildNoRepeatMediaSource(DataSource.Factory srcFactory,
ExtractorsFactory extFactory) {
MediaSource[] queue = new MediaSource[mQueue.size()];
for (int i = 0; i < queue.length; i++) {
Uri uri = mQueue.get(i).getLocation();
queue[i] = new ExtractorMediaSource(uri, srcFactory, extFactory, null, null);
}
return new ConcatenatingMediaSource(queue);
}
示例7: initPlayer
import com.google.android.exoplayer2.source.ConcatenatingMediaSource; //导入依赖的package包/类
private void initPlayer(String url) {
// 1.创建一个默认TrackSelector,测量播放过程中的带宽。 如果不需要,可以为null。
DefaultBandwidthMeter bandwidthMeter = new DefaultBandwidthMeter();
//从MediaSource中选出media提供给可用的Render S来渲染,在创建播放器时被注入
TrackSelection.Factory videoTrackSelectionFactory =
new AdaptiveTrackSelection.Factory(bandwidthMeter);
TrackSelector trackSelector =
new DefaultTrackSelector(videoTrackSelectionFactory);
// 2.创建一个默认的LoadControl
//Create a default LoadControl 控制MediaSource缓存media
DefaultLoadControl loadControl = new DefaultLoadControl();
// BufferingLoadControl bufferingLoadControl = new BufferingLoadControl();
//生成加载媒体数据的DataSource实例。
// dataSourceFactory = new DefaultDataSourceFactory(this,
// Util.getUserAgent(this, "aitrip"), bandwidthMeter);
//自定义解密工厂
aitripFactory = new AitripDataSourceFactory(this,
Util.getUserAgent(this, "aitrip"), bandwidthMeter);
extractorsFactory = new DefaultExtractorsFactory();
// factory = new DiyExtractorsFactory();
FileDataSource fileDataSource = new FileDataSource();
//test mp3
// url = "https://storage.googleapis.com/exoplayer-test-media-0/play.mp3";
// MediaSource代表要播放的媒体。
videoSource = new ExtractorMediaSource(Uri.parse(url),
aitripFactory, extractorsFactory, null, null);
// 3.创建播放器
player = ExoPlayerFactory.newSimpleInstance(this, trackSelector, loadControl);
//SimpleExoPlayerView simpleExoPlayerView = (SimpleExoPlayerView) findViewById(R.id.exo_player);
//设置监听器
player.addListener(eventListener);
//装载多个资源
MediaSource[] mediaSources = new MediaSource[1];
// mediaSources[0] = buildMediaSource(Uri.parse(huai), "");
// mediaSources[1] = buildMediaSource(Uri.parse(deng), "");
mediaSources[0] = buildMediaSource(Uri.parse(deng), "");
// mediaSources[2] = buildMediaSource(playerUri, "");
// mediaSources[3] = buildMediaSource(Uri.parse(deng), "");
ConcatenatingMediaSource mediaSource = new ConcatenatingMediaSource(mediaSources);
//设置资源
player.prepare(mediaSource);
window = new Timeline.Window();
}