{"id":617,"date":"2013-11-27T20:00:31","date_gmt":"2013-11-27T20:00:31","guid":{"rendered":"http:\/\/powered-by-haiku.co.uk\/?p=617"},"modified":"2013-12-20T09:49:24","modified_gmt":"2013-12-20T09:49:24","slug":"how-to-enable-video-captions-with-jw-player-6-when-viewing-on-mobile-ios7","status":"publish","type":"post","link":"http:\/\/powered-by-haiku.co.uk\/?p=617","title":{"rendered":"How to enable video captions with JW Player 6 when viewing on mobile iOS7"},"content":{"rendered":"<p><strong>JW Player 6 doesn&#8217;t currently* support WebVTT captions \/ subtitles when playing video on mobile iOS7.<\/strong> <em>* the current version being 6.7.4071<\/em><\/p>\n<p><strong>Here&#8217;s how you can fix that&#8230;<\/strong><\/p>\n<p>1) Set up JW Player normally, <a href=\"http:\/\/www.longtailvideo.com\/support\/jw-player\/28845\/adding-video-captions\">including the <code>tracks<\/code> block<\/a> where applicable:<\/p>\n<p><code class=\"code-block\">jwplayer(\"...\").setup({...});<br \/>\n<\/code><\/p>\n<p>2) Get a handle to the JW instance<\/p>\n<p><code class=\"code-block\">var jwp = jwplayer(\"...\");<br \/>\n<\/code><\/p>\n<p>3) Attach the following onPlay listener<\/p>\n<p><code class=\"code-block\">jwp.onPlay(function() {<br \/>\n&nbsp;&nbsp;if(jwplayer.utils.isIOS()){<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;\/* Get the video *\/<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;var oVid = jwp.container.getElementsByTagName(\"video\")[0];<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;if(oVid){<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/* Remove existing tracks  *\/<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var oTracks = oVid.getElementsByTagName(\"track\");<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(oTracks){<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for(var tr=oTracks.length,tre=0; tr>=tre; tr--){<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(oTracks[tr]) oVid.removeChild(oTracks[tr]);<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/* Add this playlist item tracks *\/<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var oPLI = jwp.getPlaylistItem();<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(oPLI && oPLI[\"tracks\"] && oPLI[\"tracks\"].length>0){<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for( var tr in oPLI[\"tracks\"]){<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var oTR = oPLI[\"tracks\"][tr];<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var oTrackTag = document.createElement(\"track\");<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for(var attr in oTR){<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var sAttr = (attr==\"file\"?\"src\":attr);<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(attr!=\"default\"||(attr==\"default\" && oTR[attr]==true)) oTrackTag.setAttribute(sAttr,oTR[attr]);<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;oVid.appendChild(oTrackTag);<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;}<br \/>\n&nbsp;&nbsp;}<br \/>\n});<br \/>\n<\/code><\/p>\n<p>That&#8217;s it! Enjoy captioned video on your iPhone. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>JW Player 6 doesn&#8217;t currently* support WebVTT captions \/ subtitles when playing video on mobile iOS7. * the current version being 6.7.4071 Here&#8217;s how you can fix that&#8230; 1) Set up JW Player normally, including the tracks block where applicable: jwplayer(&#8220;&#8230;&#8221;).setup({&#8230;}); 2) Get a handle to the JW instance var jwp = jwplayer(&#8220;&#8230;&#8221;); 3) Attach&hellip; <a href=\"http:\/\/powered-by-haiku.co.uk\/?p=617\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10],"tags":[],"class_list":["post-617","post","type-post","status-publish","format-standard","hentry","category-jw-player"],"_links":{"self":[{"href":"http:\/\/powered-by-haiku.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/617","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/powered-by-haiku.co.uk\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/powered-by-haiku.co.uk\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/powered-by-haiku.co.uk\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/powered-by-haiku.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=617"}],"version-history":[{"count":9,"href":"http:\/\/powered-by-haiku.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/617\/revisions"}],"predecessor-version":[{"id":626,"href":"http:\/\/powered-by-haiku.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/617\/revisions\/626"}],"wp:attachment":[{"href":"http:\/\/powered-by-haiku.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=617"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/powered-by-haiku.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=617"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/powered-by-haiku.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=617"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}