set youtube player lang based on user pref and enable captions when not English

Change-Id: I3208074713d3f7b571a22a7ef8f18a9131827e98
This commit is contained in:
smain@google.com 2014-12-12 11:57:27 -08:00
parent d24088c08d
commit 481f15c172

View file

@ -595,6 +595,8 @@ function onYouTubeIframeAPIReady() {
function startYouTubePlayer(videoId) {
var idAndHash = videoId.split("#");
var startTime = 0;
var lang = getLangPref();
var captionsOn = lang == 'en' ? 0 : 1;
if (idAndHash.length > 1) {
startTime = idAndHash[1].split("t=")[1] != undefined ? idAndHash[1].split("t=")[1] : 0;
}
@ -603,7 +605,7 @@ function startYouTubePlayer(videoId) {
height: '529',
width: '940',
videoId: idAndHash[0],
playerVars: {start: startTime},
playerVars: {start: startTime, hl: lang, cc_load_policy: captionsOn},
events: {
'onReady': onPlayerReady,
'onStateChange': onPlayerStateChange