Exoplayer: Play video and audio MediaSource together v 2.0.0

Created on 15 Sep 2016  路  3Comments  路  Source: google/ExoPlayer

After reading guide i am trying run play looped video and audio together.
If run this

MediaSource audio = new ExtractorMediaSource(Uri.parse(".../audio.mp3"), mediaDataSourceFactory, new DefaultExtractorsFactory(), mainHandler, null);
MediaSource video = new ExtractorMediaSource(Uri.parse(".../video.mp4"), mediaDataSourceFactory, new DefaultExtractorsFactory(), mainHandler, null);
player.prepare(new MergingMediaSource(video, audio));

everything work fine but video not looped.
But if i loop video MediaSource

MediaSource audio = new ExtractorMediaSource(Uri.parse(".../audio.mp3"), mediaDataSourceFactory, new DefaultExtractorsFactory(), mainHandler, null);
MediaSource video = new ExtractorMediaSource(Uri.parse(".../video.mp4"), mediaDataSourceFactory, new DefaultExtractorsFactory(), mainHandler, null);
player.prepare(new MergingMediaSource(new LoopingMediaSource(video), audio));

nothing happen. Even onPlayerError not called and LogCat is empty

enhancement

Most helpful comment

Yes, this is indeed a bug. We will fix this and provide better documentation regarding the expected behavior of the merging media sources in the next push. Thanks for reporting this.

All 3 comments

Yes, this is indeed a bug. We will fix this and provide better documentation regarding the expected behavior of the merging media sources in the next push. Thanks for reporting this.

To clarify somewhat: When using MergingMediaSource the expectation is that you're merging items that have the same duration. If you were to do that and then loop the merged result (example below) then I'd expect playback to proceed correctly.

MediaSource audio = new ExtractorMediaSource(Uri.parse(".../audio.mp3")...);
MediaSource video = new ExtractorMediaSource(Uri.parse(".../video.mp4")...);
player.prepare(new LoopingMediaSource(new MergingMediaSource(video, audio)));

I'm not sure this (i.e. merged playback of media items with different durations) is really something we intend to fix. You can use two separate player instances for such cases.

Was this page helpful?
0 / 5 - 0 ratings