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

No method to dynamically change <tracks> #2628

Closed
hparra opened this issue Sep 22, 2015 · 9 comments
Closed

No method to dynamically change <tracks> #2628

hparra opened this issue Sep 22, 2015 · 9 comments
Assignees
Milestone

Comments

@hparra
Copy link

hparra commented Sep 22, 2015

This is probably related to #2369.

I was looking for something similar to player.src([{}]) but for tracks. I have browsed issues at https://github.com/videojs/video.js/milestones/Text%20Tracks and read https://github.com/videojs/video.js/blob/stable/docs/guides/tracks.md but I am still confused by how related TextTrack API is supposed to work. Any clarification and known pitfalls would help me to take a stab at this.

I'm still on 4.x and would be implementing anything against that.

Related: Would a method to dynamically change all video child tags at once be useful? I could see why changing just the tracks mid-play would be a more difficult change.

@hparra
Copy link
Author

hparra commented Oct 2, 2015

Anyone? @heff?

@gkatsev gkatsev added this to the Text Tracks milestone Oct 2, 2015
@gkatsev
Copy link
Member

gkatsev commented Oct 2, 2015

The API for working with text tracks currently mimic the native text track APIs.
There's a player.addTextTrack which creates a programmatic text track and allows you to manually add cues to that track that you get.
Also, more useful to you, there's player.addRemoteTextTrack, this is a function that takes an object that looks pretty similar to the track element. It will then go and create the track for you. There's a corresponding player.removeRemoteTextTrack method to remove these. Note, you cannot remove tracks created by player.addTextTrack
You can also see what tracks are available by getting them in player.textTracks() or just the remote tracks with player.remoteTextTracks().
A quick way to swap out all the tracks would be to grab each of them with player.remoteTextTracks, remove them with player.removeRemoteTextTracks, and then add new ones with player.addRemoteTextTracks. Maybe something like:

var oldTracks = player.remoteTextTracks();
var i = oldTracks.length;
while (i--) {
  player.removeRemoteTextTrack(oldTracks[i]);
}
myNewTracks.forEach(function(track) {
  player.addRemoteTextTrack(track);
});

And yes, we really need to fix up and update our documentation relating to text tracks and how to use them. Anyway, hope the above helps for now!

@gkatsev
Copy link
Member

gkatsev commented Oct 19, 2015

@hparra does my previous comment help? Sorry for the delayed responses.

@hparra
Copy link
Author

hparra commented Oct 19, 2015

Thanks @gkatsev. Not sure yet, other fires... Were there (planned) changes in between 4.x and 5.x?

@gkatsev
Copy link
Member

gkatsev commented Oct 19, 2015

There was a change between v4 and v5 around the main text track list object that videojs has but that shouldn't affect you.
Ok, let me know when you get a chance. I'll leave it open.

@hparra
Copy link
Author

hparra commented Feb 2, 2016

Thanks again @gkatsev. Was also bitten by nativeTextTracks as mentioned in #2124.

Was the example in your comment supposed to remove the <li> children from the Chapter menu as well? It is not doing so, even though it is hiding the button.

@gkatsev
Copy link
Member

gkatsev commented Feb 2, 2016

Yeah, I think there are problems with the chapters menu right now. I'll be investigating them this week.

@hparra
Copy link
Author

hparra commented Feb 2, 2016

OK. FYI, this is with final version in 4.x series. Any clues for poking around welcomed. Was some listener supposed to remove them?

@gkatsev
Copy link
Member

gkatsev commented Apr 20, 2016

Closed by 18cdf08

@gkatsev gkatsev closed this as completed Apr 20, 2016
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 27, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants