Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tracking HTML5 Video Closed Captions Visibility State

I am attempting to determine if the TextTrack element of a html video is currently showing or hidden.

I took a look at the html specifications and at first glance, the texttracks.mode property would work perfectly according to: http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#text-track-hidden

I tested this property with the following html and code in google chrome version 35.0.1916.153:

HTML:

<video>
    <track id="en" kind="subtitles" src="transcript.vtt"></track>
    <source src = "samplevideo.mp4">
</video>

Code:

$(video)[0].textTracks[0].mode

Initially the code returns a "hidden", as expected, and upon clicking the transcript button on the video player and rerunning the code, it returns "showing".

If I toggle the player off after these steps and rerun the code, it still returns "showing" despite the transcripts being hidden on the video.

Is there a better way to detect the visible / non-visible state of transcripts on an html5 video player?

like image 508
Modulo Avatar asked Jul 16 '14 19:07

Modulo


People also ask

How do you check if a video has closed captions?

Closed captions are usually noted on a video player with a CC icon.

How to add track to video HTML?

Add a Track Element to Your Video's HTML Code Open up your website's HTML editor and view the code for the video that needs captions. Add a track tag with the following information: src – the URL location of the caption file on your server. label – the title of the track as it displays for the viewer.

How do I see closed captions?

Go to Settings. Scroll down, and select Accessibility. Scroll down, and select Subtitles & Captioning. Enable the Closed Captions + SDH feature.


1 Answers

<video id="video" controls preload="metadata">
<source src="video/sintel-short.mp4" type="video/mp4">
<source src="video/sintel-short.webm" type="video/webm">
<track label="English" kind="captions" srclang="en" src="captions/vtt/sintel-en.vtt" default>
<track label="Deutsch" kind="captions" srclang="de" src="captions/vtt/sintel-de.vtt">
<track label="Español" kind="captions" srclang="es" src="captions/vtt/sintel-es.vtt">
</video>
like image 192
lalita chiddre Avatar answered Oct 02 '22 22:10

lalita chiddre