Exoplayer HLS doesn't show subtitle


Exoplayer HLS doesn't show subtitle



I am developing a streaming app. I used for this purpose exoplayer2. I am using HLS streaming protocol. I need to show subtitle when streaming my videos. Everything goes well except subtitle. My player doesn't show the sample subtitle.
My code is as following:


uri = Uri.parse(url);
videoSource = new HlsMediaSource.Factory(DATA_SOURCE_FACTORY).createMediaSource(uri);
Uri uri1 = Uri.parse("https://bitdash-a.akamaihd.net/content/sintel/hls/subtitles_en.vtt");

Format subtitleFormat = Format.createTextSampleFormat(
null, // An identifier for the track. May be null.
MimeTypes.APPLICATION_SUBRIP, // The mime type. Must be set correctly.
Format.NO_VALUE, // Selection flags for the track.
"en");

DefaultBandwidthMeter bandwidthMeter2 = new DefaultBandwidthMeter();
DefaultDataSourceFactory dataSourceFactory = new DefaultDataSourceFactory(this,
Util.getUserAgent(this, "ExoCastDemoPlayer"), bandwidthMeter2);
subtitleSource = new SingleSampleMediaSource.Factory(dataSourceFactory).createMediaSource(uri1,subtitleFormat, C.TIME_UNSET);
MergingMediaSource mergedSource = new MergingMediaSource(videoSource, subtitleSource);
player.prepare(mergedSource);
player.seekTo(currentPosition);
player.setPlayWhenReady(true);
player.addListener(new IPlayerEventListener(this));
dropdown = findViewById(R.id.exo_resolution);
adapter = new SpinnerAdapter(this, items);
dropdown.setAdapter(adapter);
dropdown.setOnItemSelectedListener(new SpinnerOnItemSelectedListener());



I followed the developer guide of exoplayer to show subtitle but for nothing.
Thanks in advance.









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Comments

Popular posts from this blog

paramiko-expect timeout is happening after executing the command

how to run turtle graphics in Colaboratory

Export result set on Dbeaver to CSV