I implemented a listener for the 'cuechange' event on a Text Track and it's functioning correctly. However, I am unable to figure out how to remove this listener. I have attempted the instructions below to remove the listener, but it continues to be invoked.
onHiliteSpeech() {
const textTrack = this.videojsComponent.getTextTrack();
const handleCueChange = () => {
...
console.log("in event handler");
}
};
if (this.bevents) {
textTrack.addEventListener('cuechange', handleCueChange);
} else {
// None of the following instructions successfully remove the listener.
textTrack.removeEventListener('cuechange', handleCueChange);
// textTrack.removeAllListeners();
// textTrack.removeAllListeners('cuechange');
// textTrack.eventListeners = null;
}
}
Within my videojsComponent:
getTextTrack(): TextTrack {
return this.player.textTracks()[0];
}