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

hidden captions textTrack not triggering "cuechange" events #5308

Closed
ghost opened this issue Jul 10, 2018 · 9 comments · May be fixed by CleverTap/vue-video-player#3
Closed

hidden captions textTrack not triggering "cuechange" events #5308

ghost opened this issue Jul 10, 2018 · 9 comments · May be fixed by CleverTap/vue-video-player#3

Comments

@ghost
Copy link

ghost commented Jul 10, 2018

Description

When setting a 'captions' text track to 'hidden' mode and adding a cuechange event, the events are not being fired.

Steps to reproduce

  1. set the captions track to hidden
  2. add cuechange event listener
  3. send some cue events

Results

Expected

cuechange event triggered with the data

Actual

event is not being triggered, but works when setting the track mode to 'showing'

Error output

no error output

Additional Information

versions

videojs

7.11

browsers

Chrome Latest

OSes

OSX

@gkatsev
Copy link
Member

gkatsev commented Jul 13, 2018

Can you provide a reduced test case? Just tried the following and it's working for me.

var player = videojs('myplayer');
player.on('loadedmetadata', function() {
  var track = player.textTracks()[0];
  track.on('cuechange', (e) => console.log(track.activeCues));
  track.mode = 'hidden';
});

@sgrogov
Copy link

sgrogov commented Sep 10, 2018

Hello,

I've got the same problem.
Here is reduced test case https://github.com/sgrogov/bug-cases/tree/master/videojs/mode-hidden-cuechange.

My code is pretty similar to yours

player.on('loadedmetadata', function() {
	const trackElement = p.addRemoteTextTrack({src: 'captions.vtt'}, false);
	trackElement.addEventListener('load', function() {
		const track = this.track;
		track.addEventListener('cuechange', printActiveCuesContent);
		track.mode = 'hidden';
	});
});

but cuechange callback is never fired.

I tried your code but it threw an error because the track variable is undefined.

@ghost
Copy link
Author

ghost commented Sep 21, 2018

@gkatsev sorry for my late reply, your code works but only with the metadata track, which is not what i'm looking for, i'm pushing a subtitles track in a live event and that's the one i need to work on, when i try to add the listener to it nothing gets triggered, it works perfectly if i manually select the CC track from the button, the problem is that i want to render it somewhere else and not on the player so i need it to be hidden or to hide it in another way (on both mobile and desktop clients of course)

here's a test case:

player.on('loadedmetadata', function() {
    var track = player.textTracks()[1];
    track.on('cuechange', (e) => console.log(track.activeCues));
    track.mode = 'hidden';
});

@gkatsev
Copy link
Member

gkatsev commented Sep 21, 2018

OH, I see. Also, I realize what the issue is now. If you set the mode to showing and then hidden programmatically or not, it'll work.
Looks like when the mode is changed, we only enable the updates if it's being set to showing. Why? I'm not sure, probably something silly:

if (mode === 'showing') {
this.tech_.ready(() => {
this.tech_.on('timeupdate', timeupdateHandler);
}, true);
}

We probably want to update that line to look more like this one:

if (mode !== 'disabled') {
this.tech_.ready(() => {
this.tech_.on('timeupdate', timeupdateHandler);
}, true);
}

Would you be interested in making a PR for that?

@gkatsev
Copy link
Member

gkatsev commented Sep 21, 2018

Actually, even worse, looks like we never disable the timer once set. I'll make the PR since there's more going on there.

@ghost
Copy link
Author

ghost commented Sep 25, 2018

@gkatsev thanks so much, will test ASAP and get back to you

gkatsev added a commit that referenced this issue Sep 25, 2018
We were only triggering cuechange events if a metadata track started out as not disabled or only when setting the mode to 'showing'

Fixes #5308
@gkatsev
Copy link
Member

gkatsev commented Sep 26, 2018

@kalieye it's out now in 7.2.5, let us know if you still have issues.

@ghost
Copy link
Author

ghost commented Sep 27, 2018

@gkatsev i updated and i can confirm that the issue is now fixed, thank you!

@gkatsev
Copy link
Member

gkatsev commented Sep 27, 2018

You're welcome. Thanks for checking back in!

gkatsev added a commit that referenced this issue Oct 31, 2018
We were only triggering cuechange events if a metadata track started out as not disabled or only when setting the mode to 'showing'

Fixes #5308
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 26, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants