removeCue method
Remove a specific TextTrackCue from a TextTrack's list of cues.
![]() |
Syntax
TextTrack.removeCue(cue);Parameters
- cue [in]
-
Type: TextTrackCue
The cue to remove.
Return value
This method does not return a value.
Exceptions
| Exception | Condition |
|---|---|
|
Cue is not currently listed in the TextTrack's cue list. |
Examples
You can remove an existing TextTrackCue using removeCue. This example starts playing the video, and retrieves each cue for display. When it sees the second cue, it deletes it using removeCue before it is displayed.
When you use the removeCue method, the TextTrackCue object must match a TextTrackCue on the text track, or you'll get a NotFoundError exception.
<!DOCTYPE html > <html > <head> <title>Remove Cue example</title> <meta http-equiv="X-UA-Compatible" content="IE=edge" /> </head> <body> <video id="video1" controls muted autoplay> <source src="video.mp4"> HTML5 Video not supported </video> <script type="text/javascript"> var video = document.getElementById("video1"); var beginTime, endTime, message; var newTextTrack = video.addTextTrack("captions", "sample"); newTextTrack.mode = newTextTrack.SHOWING; // set track to display // create some cues and add them to the new track for(var i=0;i<10;i++){ beginTime = i * 5 ; endTime = ( (i * 5) + 5); message = "This is number " + i; newTextTrack.addCue(new TextTrackCue(beginTime, endTime, message)); } // Watch for cue change events newTextTrack.addEventListener("cuechange", function () { // get current cue, and remove it if it's number 2 var currentCue = newTextTrack.activeCues[0]; if (currentCue.text == "This is number 2") { newTextTrack.removeCue(currentCue) } },false); </script> </body> </html>
See also
Show:
