Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to play separate audio and video together using exoplayer?

So I have two urls one for audio and one for video. I want to play them together but really couldn't find any documentation about this.

like image 583
Weston Avatar asked Nov 15 '25 10:11

Weston


1 Answers

I just found the answer just build it like below in kotlin:

 val dataSourceFactory: DataSource.Factory =
                                DefaultHttpDataSource.Factory()
                            val videoSource: MediaSource = ProgressiveMediaSource.Factory(dataSourceFactory)
                                    .createMediaSource(fromUri(videoInPlayer.videoStreams[0].url))
                            val audioSource: MediaSource = ProgressiveMediaSource.Factory(dataSourceFactory)
                                    .createMediaSource(fromUri(videoInPlayer.audioStreams[0].url))

                            val mergeSource: MediaSource = MergingMediaSource(videoSource,audioSource)
like image 104
Weston Avatar answered Nov 18 '25 04:11

Weston



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!