How To Add Multiple Subtitles In Exo Player 2
I want to show subtitles with ExoPlayer 2 . users can choose between languages (English,German, or Arabic) . Video links are HLS (.m3u8) and subtitles are .str files . I couldn'
Solution 1:
The link I added as a comment to your original post will be how you'll build the UI around text track selection. Then to actually get the tracks to be added to your mp4 file (or whatever the format is), you'll want to use a MergingMediaSource
. The simple version looks like so:
MediaSourcevideoSource=newExtractorMediaSource(videoUri, ...);
MediaSourcesubtitleSource=newSingleSampleMediaSource(subtitleUri, ...);
// Plays the video with the sideloaded subtitle.MergingMediaSourcemergedSource=newMergingMediaSource(videoSource, subtitleSource);
You can merge multiple subtitle tracks into the video source. Many different file formats are accepted.
I got that particular code sample from this blog post - but I believe that same code is also in the ExoPlayer documentation. That code block combined with the sample code that I link to in my other answer here should be enough to get you some subtitles.
Please let me know if that works for you.
Post a Comment for "How To Add Multiple Subtitles In Exo Player 2"