Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add mediaPlayer.addTextTrack() #3573

Open
wants to merge 9 commits into
base: development
Choose a base branch
from

Conversation

malthejorgensen
Copy link

This is a proof-of-concept for allowing adding captions/subtitles that are not listed in the manifest.

See issue: #3572

This method allows for loading captions from a file not listed in the
manifest.
if (data.indexOf('WEBVTT') > -1) {
return VTTParser(context).getInstance();
}
// } else if (data.indexOf('MPD') > -1 || data.indexOf('Patch') > -1) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove comments

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 97006db

captionsLoader.reset();
};

eventBus.on(Events.EXTERNAL_CAPTIONS_LOADED, handler, self);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this event be captured by the TextSourceBuffer instead and cause createTextTrackFromMediaInfo() to be called? Instead of duplicating the code?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are totally right, I think the current structure is an artifact of how I wrote the change initially.

Change done in 39773bb

}

/********* END ***********/
let captionsLoader = createCaptionsLoader();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to create a new instance of CaptionsLoader every time? Might consider creating a single instance as part of TextController and then call textController.getCaptionsLoader

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you're right, but I'm not sure how to do it. Currently the CaptionsLoader inherits requestModifier and mssHandler from the MediaPlayer config. Those don't seem available from inside TextController, so I'm not sure how pass those along if it's created in TextController.setup().

Move `EXTERNAL_CAPTIONS_LOADED`-event listener into TextSourceBuffer
and to allow reusing `createTextTrackFromMediaInfo`.
This requires passing `mediaInfo` to CaptionsLoader and adding the
passed MediaInfo to `TextSourceBuffer.mediaInfos`.

Also removes `TextTracks.getNumberOfTextTracks()` which is no longer
needed.
@dsilhavy dsilhavy modified the milestones: 3.2.2, 4.0.0 Apr 6, 2021
@dsilhavy
Copy link
Collaborator

@malthejorgensen Sorry for the delay on my end. We are currently working on version 4.0 including major changes to the general structure of dash.js. Once this is done I will get back to your PR

@dsilhavy dsilhavy modified the milestones: 4.0.0, 4.0.1 May 28, 2021
@dsilhavy dsilhavy removed this from the 4.0.1 milestone Jun 27, 2021
@francoism90
Copy link

Will this be merged? This is really useful when the backend doesn't support adding tracks in the manifest. :)

@francoism90
Copy link

2 years later.. any update on this? I'm now creating a HTMLTrack element as workaround.

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants