question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

When creating MediaSource using createMediaSource(mediaItem) and it was populated with subtitles the player will not consider them as text tracks

See original GitHub issue

Hi,

Given MediaItem.Subtitle list is missing in playback text tracks if the MediaSource is built from given MediaItem having the subtitles

When I was trying to explore the usage MediaSource instead of MediaItem for the Playback URL headers modifications

I have populated the MediaItem playback params with the external subtitles. I could not see that external subtitle in the tracks dialog when I tested this solution

I have modified a bit the demo app main activity to call setMediaSource instead of setMediaItems I have also assumed that single non drm dash media without subtitles is selected.

I have populated subtitleList and set it to mediaItem in pos 0. created a dash media source
and called player.setMediaSource(dashMediaSource,!haveStartPosition); instead of player.setMediaItems(mediaItems, /* resetPosition= */ !haveStartPosition);

then called prepare

List<MediaItem.Subtitle> subtitleList = new ArrayList<>();
String url = "https://storage.googleapis.com/exoplayer-test-media-1/webvtt/numeric-lines.vtt";
MediaItem.Subtitle externalSubtitle = new MediaItem.Subtitle(Uri.parse(url), MimeTypes.TEXT_VTT,"en", C.SELECTION_FLAG_DEFAULT, C.ROLE_FLAG_SUBTITLE, "ENGLISH-EXTERNAL");
subtitleList.add(externalSubtitle);
...
mediaItems.get(0).buildUpon().setSubtitles(subtitleList);
...
DashMediaSource dashMediaSource = new DashMediaSource.Factory(new DefaultDashChunkSource.Factory(dataSourceFactory), dataSourceFactory).createMediaSource(mediaItems.get(0));
player.setMediaSource(dashMediaSource,!haveStartPosition);
//player.setMediaItems(mediaItems, /* resetPosition= */ !haveStartPosition);
player.prepare();

Version: Exo Player version: 2.12.3 Android 10 Samsung Galaxy 10e

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
ojw28commented, Jan 19, 2021

Ah right, yes, you do need a MediaItem to give to the non-deprecated createMediaSource methods, even when building a MediaSource instances outside of the player. So point (2) of my previous response wasn’t really correct.

Point (1) still is correct though: If you need side-loaded subtitle support then you should use DefaultMediaSourceFactory rather than DashMediaSource.Factory. DefaultMediaSourceFactory has the additional logic needed to build a MergingMediaSource for the side-loaded subtitles. Alternatively, you can use DashMediaSource.Factory to build a DashMediaSource, and then you can wrap it in a MergingMediaSource yourself.

It is a bit confusing that some of the MediaSourceFactory implementations only support a subset of what can be specified in the MediaItem. In this example, it’s confusing that DashMediaSource.Factory does not support side-loaded subtitles. We will have a think about how best to document or resolve this.

0reactions
giladnacommented, Jan 19, 2021

@ojw28 Got it, The I am wondering what is the benefit that we need to give the mediaItem itself to the createMediaSource and not using url in the deprecated api which build the media source? the API actually forces to use MediaItem even if it is not a must.

What do I miss.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Media sources - ExoPlayer
In ExoPlayer every piece of media is represented by a MediaItem . However internally, the player needs MediaSource instances to play the content....
Read more >
Media3 - Android Developers
Create an instance with MetadataRenderer(MetadataOutput, Looper, MetadataDecoderFactory, boolean) to specify whether the renderer will output metadata early or ...
Read more >
Does ExoPlayer create a windowIndex for each media source ...
This is not really an answer but the explanation to why when I called seekTo(windowIndex, position) the player seemed like it was ignoring ......
Read more >
Media Source Extensions™ - W3C
Data from the SourceBuffer objects is managed as track buffers for audio, video and text data that is decoded and played. Byte stream ......
Read more >
RELEASENOTES.md · master · Lahlouh, Ishak / RFC_Player
For example Player.VideoComponent is now ExoPlayer.VideoComponent . The most used methods of Player 's audio, video, text and metadata ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found