Youtube Closed Caption for HTML5 Not Working -



Youtube Closed Caption for HTML5 Not Working -

i having issues displaying closed caption on youtube videos using iframe player.

here's code using:

<!doctype html> <html> <body> <!-- 1. <iframe> (and video player) replace <div> tag. --> <div id="player"></div> <script> // 2. code loads iframe player api code asynchronously. var tag = document.createelement('script'); tag.src = "https://www.youtube.com/iframe_api"; var firstscripttag = document.getelementsbytagname('script')[0]; firstscripttag.parentnode.insertbefore(tag, firstscripttag); // 3. function creates <iframe> (and youtube player) // after api code downloads. var player; function onyoutubeiframeapiready() { player = new yt.player('player', { height: '390', width: '640', videoid: 'm7lc1uvf-ve', events: { 'onready': onplayerready, 'onstatechange': onplayerstatechange } }); } // 4. api phone call function when video player ready. function onplayerready(event) { event.target.playvideo(); } // 5. api calls function when player's state changes. // function indicates when playing video (state=1), // player should play 6 seconds , stop. function onplayerstatechange(event) { event.target.loadmodule('captions'); } </script> </body> </html>

here's gist https://gist.github.com/khirakawa/0a81b3039a85b9875b59

this same sample code that's on api reference page, https://developers.google.com/youtube/iframe_api_reference. phone call event.target.loadmodule('captions'); on player state alter event.

i not find documentation on api reference page loading caption modules, did find code load caption module in ticket https://code.google.com/p/gdata-issues/issues/detail?id=444

i tried on both safari , chrome no luck.

the local storage values see when youtube opened is:

yt-remote-connected-devices {"data":"[]","expiration":1412291704974,"creation":1412205304974} yt-remote-device-id {"data":"27238aac-9452-4ae8-9b9f-1e29278e4d3b","expiration":1443741293991,"creation":1412205293992} yt-remote-load-account-screens {"data":"false","expiration":1443741304972,"creation":1412205304972} yt-remote-online-screens {"data":"[]","expiration":1412205364973,"creation":1412205304973}

notice missing entries captions (i can't recall key values were, know there 2 of them. 1 enable captions , other caption settings).

the demo page (https://developers.google.com/youtube/youtube_player_demo) shows closed captions if check cc_load_policy, that's as3 option.

this working on oct 6th, cannot work anymore. i'm not sure if youtube script changed.

i tried moving event.target.loadmodule('captions'); onplayerready handler, didn't work either.

any help appreciated.

i able load captions setting cc_load_policy 1. realized sample video on youtube site defaulting using <embed> (read: flash), instead of using html5 video player.

i not when iframe player decides utilize on , did find video utilize html5 video tag. so, had set cc_load_policy 1 in order work. neither loadmodule nor unloadmodule works anymore.

i hope helps else ran issue.

youtube youtube-iframe-api

Comments

Popular posts from this blog

c# - ASP.NET MVC Sequence contains no matching element -

java - Parsing XML, skip certain tags -

rest - How to invalidate user session on inactivity in a stateless server? -