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't find any samples to do this.
is there any sample?
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:
MediaSource videoSource = new ExtractorMediaSource(videoUri, ...);
MediaSource subtitleSource = new SingleSampleMediaSource(subtitleUri, ...);
// Plays the video with the sideloaded subtitle.
MergingMediaSource mergedSource = new MergingMediaSource(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.
Related
I am trying to integrate subtitles into videos using Exoplayer. Currently only .srt subtitle files are working with MIMETypes.APPLICATION_SUBRIP. How do I make it work for .smi subtitle files.
MediaItem.SubtitleConfiguration subtitleConfiguration = new MediaItem.SubtitleConfiguration.Builder(Uri.parse(subTitlePath))
.setMimeType(MimeTypes.APPLICATION_SUBRIP)//mime type
.setSelectionFlags(C.SELECTION_FLAG_DEFAULT)
.build();
MediaItem mediaItem=new MediaItem.Builder()
.setUri(Uri.parse(videoUri))
.setSubtitleConfigurations(ImmutableList.of(subtitleConfiguration))
.build();
According to below thread (issue in github),
Ref : https://github.com/google/ExoPlayer/issues/5869
The answer is that it is not possible to play that with the ExoPlayer at the moment, because we don't have a decoder for SAMI subtitles.
But in the future may we have the decoder and more support from ExoPlayer.
I'm working with the Pac-12 API (college sports data) and trying to make a streaming video player.
The Pac-12 API (http://api.pac-12.com/v3/vod?page=0") gives back a list of video objects with urls for their Video's on Demand (VODs).
I have exo player set up in Android and it's working for videos with urls that end in .mp4.
But when I try to plug in the VOD urls it's giving an error that it cannot extract the file type.
I'm using exo player 2.8.4 which may or may not be the problem. But the newer version of exo player ( 2.9.0 and above ) has min sdk 26 (which my testing phone doesn't run).
I'm working on checking if that's the problem, but in the mean time I wanted to post this question in case anyone can help.
Here is my exo player set up. mediaUrl is the varaible that works with .mp4 but not the VOD url.
DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(
context, Util.getUserAgent(context, "RecyclerView VideoPlayer"));
String mediaUrl = mediaObjects.get(targetPosition).getMedia_url();
if (mediaUrl != null) {
MediaSource videoSource = new ExtractorMediaSource.Factory(dataSourceFactory)
.createMediaSource(Uri.parse(mediaUrl));
videoPlayer.prepare(videoSource);
videoPlayer.setPlayWhenReady(true);
}
The VOD urls give no file type extension at the end, so I tried concatenating '.vod' onto the mediaUrl varaible, but no luck with that.
From reading around online it seems like VODs are supported by exo player, but I can't find much about how the setup might be different.
Heres a direct link to one of the Pac-12 VODs. This is the same url as what the API returns.
https://pac-12.com/videos/oregons-dana-altman-talks-andy-katz-about-recruitment-getting-fans-back-and-more
How to play multiple URLs sequentially in android? I have a small streaming url 10s/each of one complete song. I need to play it one after another. Is there any way doing it so the music don't get lagged?
https://exoplayer.dev/media-sources.html read Advanced composition
MediaSource firstSource =
new ProgressiveMediaSource.Factory(...).createMediaSource(firstVideoUri);
MediaSource secondSource =
new ProgressiveMediaSource.Factory(...).createMediaSource(secondVideoUri);
// Plays the first video twice, then the second video.
ConcatenatingMediaSource concatenatedSource =
new ConcatenatingMediaSource(firstSource, firstSource, secondSource);
It looks like you are using the m3u8 playlist to play with MediaPlayer. However, you wouldn't able to do it. You can use ExoPlayer to play m3u8 list. Check this link
https://github.com/google/ExoPlayer
simpleExoPlayerView.setShowMultiWindowTimeBar(true);
i am newbie here. i am developing a android app to listen to online radio stations.
problem i am getting here is ExoPlayer(2.9.2) can or cant play some streams of same type of different bitrates.
For Example
These mpga streams
http://108.61.34.50:7130/ ---> 96kbs ===> Playable
http://s3.voscast.com:8408 ---> 64kbs ===> Not Playable
http://220.247.227.20:8000/citystream ---> 128kbs ===> Not Playable
i used vlc codec window to get this information, and those 3 streams share same values other than bitrate.
i am using ExtractorMediaSource
songs.add(Uri.parse("http://220.247.227.20:8000/citystream"));//City
player= ExoPlayerFactory.newSimpleInstance(this,
new DefaultTrackSelector());
DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(this,
Util.getUserAgent(this, "AudioApp"));
ConcatenatingMediaSource concatenatingMediaSource = new ConcatenatingMediaSource();
for (Uri temp : songs)
{
BaseMediaSource mediaSourse=
new ExtractorMediaSource.Factory(dataSourceFactory).createMediaSource(temp);
concatenatingMediaSource.addMediaSource(mediaSourse);
}
player.prepare(concatenatingMediaSource);
player.setPlayWhenReady(true);
Hope anyone can help me out..
After testing various different streams, i realized that this is a device specific error.
Huawei Y5 2017
the other phone's that i tested work pretty well and i ended up submiting issue to ExpoPlayer team on github without knowing this is device specific issue.
Here it is
Why does ExoPlayer cant play some of the streams of same type with different bitrates ?
Hi I am looking for an example to configure ExoPlayer for DASH. But the example I found uses Youtube videos. Is there an example on videos which are not on youtube? Can DASH be configured for any video on the internet?
Yes, ExoPlayer can play any DASH, SmoothStreaming, HLS or MP4 Progressive download over HTTP URLs.
The demo application provided in ExoPlayer source code can be modified to add any video that will be shown in the startup Activity. To do that, edit https://github.com/google/ExoPlayer/blob/master/demo/src/main/java/com/google/android/exoplayer/demo/Samples.java file to add a new sample set.
Example:
public static final Sample[] CUSTOM_DASH_VIDEOS = new Sample[] {
new Sample("Some User friendly name of video 1",
"http://www.somewhere.com/somecontent.mpd?param1=val1¶m2=val2", DemoUtil.TYPE_DASH),
new Sample("Some User friendly name of video 2",
"http://www.somewhere.com/somecontent.mpd?param1=val1¶m2=val2", DemoUtil.TYPE_DASH),
};
Now, in https://github.com/google/ExoPlayer/blob/master/demo/src/main/java/com/google/android/exoplayer/demo/SampleChooserActivity.java add a new row in sample adapter.
sampleAdapter.add(new Header("Custom DASH Videos"));
sampleAdapter.addAll((Object[]) Samples.CUSTOM_DASH_VIDEOS);
Hope this answers your question.