How to play separate audio and video together using exoplayer?

Viewed 102

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.

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)
Related