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

When removing a track also remove listeners #3046

Closed
wants to merge 2 commits into from

Conversation

forbesjo
Copy link
Contributor

This PR is to remove event listeners from removed text tracks. This would be useful for a plugin like videojs-playlist.

@@ -111,6 +111,7 @@ TextTrackList.prototype.removeTrack_ = function(rtrack) {
for (let i = 0, l = this.length; i < l; i++) {
if (this[i] === rtrack) {
track = this[i];
track.off();
Copy link
Member

Choose a reason for hiding this comment

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

See the note in the doc for this method :)
The track in this list could be a native track element which won't have an off method. Can probably check track instanceof TextTrack or something.
However, because users are required to manage their listeners with native tracks, I wonder whether we should do this for the emulated tracks?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It looks like one of the tests caught that scenario. I'm checking for track.off existence since it seems like the input is still a TextTrack even though it's an element.

@@ -111,6 +111,9 @@ TextTrackList.prototype.removeTrack_ = function(rtrack) {
for (let i = 0, l = this.length; i < l; i++) {
if (this[i] === rtrack) {
track = this[i];
if (track.off) {
Copy link
Member

Choose a reason for hiding this comment

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

This works. Sorry, what I meant was checking to see if it's an instanceof videojs.TextTrack.

@forbesjo
Copy link
Contributor Author

forbesjo commented Feb 1, 2016

@gkatsev any other changes needed?

@gkatsev
Copy link
Member

gkatsev commented Feb 1, 2016

LGTM. I'll work on getting these in this week.

@gkatsev gkatsev added the minor This PR can be added to a minor release. It should not be added to a patch release. label Feb 1, 2016
@gkatsev gkatsev closed this in c8646aa Feb 2, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
confirmed minor This PR can be added to a minor release. It should not be added to a patch release.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants