{"id":14220,"date":"2015-05-07T05:06:34","date_gmt":"2015-05-06T19:06:34","guid":{"rendered":"http:\/\/www.rjmprogramming.com.au\/wordpress\/?p=14220"},"modified":"2015-05-05T16:59:47","modified_gmt":"2015-05-05T06:59:47","slug":"html5-track-element-primer-tutorial","status":"publish","type":"post","link":"https:\/\/www.rjmprogramming.com.au\/ITblog\/html5-track-element-primer-tutorial\/","title":{"rendered":"HTML5 Track Element Primer Tutorial"},"content":{"rendered":"<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/videos\/track_tutorial.jpg\"><img decoding=\"async\" id='hti' style=\"float:left;border: 15px solid pink;\" alt=\"HTML5 Track Element Primer Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/PHP\/videos\/track_tutorial.jpg\" title=\"HTML5 Track Element Primer Tutorial\" onmouseover=\" this.src=this.src.replace('.jpg','.xpng').replace('.png','.xjpg').replace('.x','.');   \"  \/><\/a><p class=\"wp-caption-text\">HTML5 Track Element Primer Tutorial<\/p><\/div>\n<p>HTML5 brought in quite a few new HTML element types (which you can read more about <a target=_blank title='HTML5 New Elements information from w3schools' href='http:\/\/www.w3schools.com\/html\/html5_new_elements.asp'>here<\/a>) and one very useful one appears in the HTML code snippet as below &#8230;<\/p>\n<p><code><br \/>\n&lt;video controls&gt;<br \/>\n  &lt;source type=\"video\/ogg; codecs=\"vp8, vorbis\"\" src=\"http:\/\/www.rjmprogramming.com.au\/PHP\/videos\/GoToMeeting.ogv\"&gt;&lt;\/source&gt;<br \/>\n  &lt;track kind=\"subtitles\" label=\"English subtitles\" src=\"http:\/\/www.rjmprogramming.com.au\/PHP\/videos\/subtitles_en.vtt\" srclang=\"en\" default&gt;&lt;\/track&gt;<br \/>\n  &lt;track kind=\"subtitles\" label=\"Deutsche Untertitel\" src=\"http:\/\/www.rjmprogramming.com.au\/PHP\/videos\/subtitles_de.vtt\" srclang=\"de\"&gt;&lt;\/track&gt;<br \/>\n&lt;\/video&gt;<br \/>\n<\/code><\/p>\n<p> &#8230; yes, it&#8217;s &lt;track&gt; and think, by the context, you can guess what it does, especially if we say you can also use it with &lt;audio&gt; &#8230; yes, as you can read <a target=_blanktitle='HTML5 Track element information here from w3schools' href='http:\/\/www.w3schools.com\/tags\/tag_track.asp'>here<\/a> &#8230;<\/p>\n<blockquote><p>\nThe &lt;track&gt; tag specifies text tracks for media elements (&lt;audio&gt; and &lt;video&gt;).\n<\/p><\/blockquote>\n<p>As it&#8217;s part of HTML5 am sure it will eventually be more acceptable across the web browsers but for now we&#8217;ll show you it working in Google Chrome.  Really it&#8217;s better to concentrate on functionality that works across the browsers, but, as with concepts like VBScript (only working with Internet Explorer) its still worth knowing about the &lt;track&gt; HTML5 element because of its support for the <i>&#8220;oncuechange&#8221;<\/i> event it triggers in the scenario of our HTML snippet above, where the track element&#8217;s &#8220;src&#8221; parameter <i>&#8220;http:\/\/www.rjmprogramming.com.au\/PHP\/videos\/subtitles_en.vtt&#8221;<\/i> is a subtitles file with a WEBVTT format you can read about <a target=_blank title='WEBVTT file format information from w3c' href='http:\/\/dev.w3.org\/html5\/webvtt\/'>here<\/a>.<\/p>\n<p>Each change of subtitle &#8220;event&#8221; in this file represents a place where the <i>&#8220;oncuechange&#8221;<\/i> event can be triggered as you play the media file, whether that be video or audio.  As you can read at this <a target=_blank href='http:\/\/www.html5rocks.com\/en\/tutorials\/track\/basics\/' title='WEBVTT and JSON'>great link<\/a> this WEBVTT format supports JSON syntax, and we use that with our <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/videos\/track_tutorial.html\" title='track_tutorial.html'>live run<\/a> (that may or may not show subtitles, and a transcription with images, using the web browser you are currently using) today (with the downloadable <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/videos\/track_tutorial.html\" title='track_tutorial.html_GETME'>track_tutorial.html<\/a> making use of the English subtitles <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/videos\/subtitles_en.vtt_GETME\" title='subtitles_en.vtt'>subtitles_en.vtt<\/a>).<\/p>\n<p>So, a bit more work and we&#8217;re getting towards YouTube, with closed captions, functionality for your videos &#8230; cute, huh?!<\/p>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#14220' onclick='var dv=document.getElementById(\"d14220\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"http:\/\/www.rjmprogramming.com.au\/wordpress\/?tag=HTML5\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d14220' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n","protected":false},"excerpt":{"rendered":"<p>HTML5 brought in quite a few new HTML element types (which you can read more about here) and one very useful one appears in the HTML code snippet as below &#8230; &lt;video controls&gt; &lt;source type=&#8221;video\/ogg; codecs=&#8221;vp8, vorbis&#8221;&#8221; src=&#8221;http:\/\/www.rjmprogramming.com.au\/PHP\/videos\/GoToMeeting.ogv&#8221;&gt;&lt;\/source&gt; &lt;track kind=&#8221;subtitles&#8221; &hellip; <a href=\"https:\/\/www.rjmprogramming.com.au\/ITblog\/html5-track-element-primer-tutorial\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12,14,37],"tags":[113,215,275,400,520,576,578,652,663,760,863,997,1218,1296,1319,1369,1404,1422,1493],"class_list":["post-14220","post","type-post","status-publish","format-standard","hentry","category-elearning","category-event-driven-programming","category-tutorials","tag-audio","tag-closed-captions","tag-cross-browser","tag-event","tag-google-chrome","tag-html","tag-html5","tag-javascript","tag-jquery","tag-media","tag-oncuechange","tag-programming","tag-subtitles","tag-track","tag-tutorial","tag-video","tag-web-browser","tag-webvtt","tag-youtube"],"_links":{"self":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/14220"}],"collection":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/comments?post=14220"}],"version-history":[{"count":1,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/14220\/revisions"}],"predecessor-version":[{"id":14630,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/14220\/revisions\/14630"}],"wp:attachment":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/media?parent=14220"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/categories?post=14220"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/tags?post=14220"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}