From d86c62664cc1fbe27403d0ddbfe5e918e8d4da51 Mon Sep 17 00:00:00 2001 From: calzoneman Date: Sun, 26 Jul 2015 13:29:06 -0700 Subject: [PATCH] Fixes for Chrome --- player/videojs.coffee | 20 +++++++++++++------- www/css/cytube.css | 4 ++++ www/js/player.js | 20 +++++++++++--------- 3 files changed, 28 insertions(+), 16 deletions(-) diff --git a/player/videojs.coffee b/player/videojs.coffee index b5039491..b58b510f 100644 --- a/player/videojs.coffee +++ b/player/videojs.coffee @@ -106,14 +106,20 @@ window.VideoJSPlayer = class VideoJSPlayer extends Player $('.vjs-waiting').removeClass('vjs-waiting') ) - $('#ytapiplayer .vjs-subtitles-button .vjs-menu-item').each((i, elem) -> - if elem.textContent == localStorage.lastSubtitle - elem.click() + # Workaround for Chrome-- it seems that the click bindings for + # the subtitle menu aren't quite set up until after the ready + # event finishes, so set a timeout for 1ms to force this code + # not to run until the ready() function returns. + setTimeout(-> + $('#ytapiplayer .vjs-subtitles-button .vjs-menu-item').each((i, elem) -> + if elem.textContent == localStorage.lastSubtitle + elem.click() - elem.onclick = -> - if this.attributes['aria-selected'].value == 'true' - localStorage.lastSubtitle = this.textContent - ) + elem.onclick = -> + if elem.attributes['aria-selected'].value == 'true' + localStorage.lastSubtitle = elem.textContent + ) + , 1) ) ) diff --git a/www/css/cytube.css b/www/css/cytube.css index 1f16c427..840f6f4a 100644 --- a/www/css/cytube.css +++ b/www/css/cytube.css @@ -635,3 +635,7 @@ table td { li.vjs-menu-item.vjs-selected { background-color: #66a8cc !important; } + +.video-js video::-webkit-media-text-track-container { + bottom: 50px; +} diff --git a/www/js/player.js b/www/js/player.js index 86692898..95688d78 100644 --- a/www/js/player.js +++ b/www/js/player.js @@ -565,16 +565,18 @@ _this.player.on('seeked', function() { return $('.vjs-waiting').removeClass('vjs-waiting'); }); - return $('#ytapiplayer .vjs-subtitles-button .vjs-menu-item').each(function(i, elem) { - if (elem.textContent === localStorage.lastSubtitle) { - elem.click(); - } - return elem.onclick = function() { - if (this.attributes['aria-selected'].value === 'true') { - return localStorage.lastSubtitle = this.textContent; + return setTimeout(function() { + return $('#ytapiplayer .vjs-subtitles-button .vjs-menu-item').each(function(i, elem) { + if (elem.textContent === localStorage.lastSubtitle) { + elem.click(); } - }; - }); + return elem.onclick = function() { + if (elem.attributes['aria-selected'].value === 'true') { + return localStorage.lastSubtitle = elem.textContent; + } + }; + }); + }, 1); }); }; })(this));