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

listen to TextTrackList.onchange event #3519

Open
jimmywarting opened this issue Jan 16, 2021 · 1 comment
Open

listen to TextTrackList.onchange event #3519

jimmywarting opened this issue Jan 16, 2021 · 1 comment

Comments

@jimmywarting
Copy link

jimmywarting commented Jan 16, 2021

I'm using both dash and hls and it have both different apis. Therefore i try to use the native video method as much as possible to try and be more isomorphic. One of those methods is to listen when a text tracks have been found and when a user wants to change the selected track.

I'm not exactly sure how hls.js dose it but this work with hls.

  1. you listen to video.textTracks.onaddtrack events
    (this lets you know that both hls and dash have found a TextTrack.)
  2. Activating one if this tracks by setting track.mode = 'showing' will start to display the selected track.

I do not thing either dash or hls have downloaded the cues already (as they are lazy loaded?)

video.textTracks.onaddtrack = ({track}) => {
  // add track to an select menu
  addOptionToSelect(racks)
}
select.onchange = () => {
  activeTrack.mode = 'disabled' // disable the previous track

  const selectedTrack = getTrackFrom(select)
  track.mode = 'showing' // activate the newly selected track
  activeTrack = track
}

This works flawless in hls.js without calling any hls methods.
it seems like if hls.js are listening to TextTrackList.onchange and starts to download it accordingly (but not entirely sure how it works under the hood)
with dash.js i must call player.setTextTrack(index) manually for the cues to be populated

What i would kind of hope for in a feature request is that you would maybe deprecate setTextTrack & getTextTrack in favor of using the videos native TextTrackList methods instead so we don't have to call any
isHLS ? hls.selectTrack(track) : dash.setTextTrack(index)

@jimmywarting jimmywarting changed the title [Feature request] listen to TextTrackList.onchange event listen to TextTrackList.onchange event Jan 16, 2021
@dsilhavy
Copy link
Collaborator

We will probably move away from native tracks as they are not properly implemented on all devices, see #4032

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

No branches or pull requests

2 participants