gpt4 book ai didi

android - Exoplayer 不循环播放视频

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:26:35 24 4
gpt4 key购买 nike

我在我的 Android 应用程序中使用 Exoplayer 来播放视频和音频文件。根据 Exoplayer developer's guide,为了循环视频/音频,这是你必须做的

MediaSource mediaSource = new ExtractorMediaSource(videoUri, ...);
// Loops the video indefinitely.
LoopingMediaSource loopingSource = new LoopingMediaSource(mediaSource);

所以我在我的Activity的onCreate方法中是这样实现的

    BandwidthMeter bandwidthMeter = new DefaultBandwidthMeter();
TrackSelection.Factory factory = new AdaptiveTrackSelection.Factory(bandwidthMeter);
TrackSelector trackSelector = new DefaultTrackSelector(factory);

simpleExoPlayer = ExoPlayerFactory.newSimpleInstance(this,trackSelector);
simpleExoPlayer.setPlayWhenReady(true);
simpleExoPlayerView.setPlayer(simpleExoPlayer);

// Measures bandwidth during playback. Can be null if not required.
bandwidthMeter2 = new DefaultBandwidthMeter();

// Produces DataSource instances through which media data is loaded.
dataSourceFactory = new DefaultDataSourceFactory(this,
Util.getUserAgent(this, applicationName), bandwidthMeter2);

// Produces Extractor instances for parsing the media data.
extractorsFactory = new DefaultExtractorsFactory();
mediaSource = new ExtractorMediaSource(videoUri,dataSourceFactory, extractorsFactory, null, null);

loopingSource = new LoopingMediaSource(mediaSource);
simpleExoPlayer.prepare(mediaSource);

但是我的视频文件没有循环播放。它只播放一次。

最佳答案

只需使用player.setRepeatMode(player.REPEAT_MODE_ONE);

关于android - Exoplayer 不循环播放视频,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44217063/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com