HTML5 video tracking

I am trying to determine if a TextTrack html video element is currently being displayed.

I took a look at the html specifications and at first glance, the texttracks.mode property will 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 “hidden”, as expected, and after pressing the transcription button on the video player and restarting the code, it returns “show”.

If I disconnect the player after these steps and repeat the code, it still returns a “show”, despite the hiding of transcripts on the video.

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

+6
source share
1 answer
 <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> 
+1
source

Source: https://habr.com/ru/post/972341/


All Articles