diff --git a/player/videojs.coffee b/player/videojs.coffee
index b8d384c3..b5039491 100644
--- a/player/videojs.coffee
+++ b/player/videojs.coffee
@@ -68,12 +68,15 @@ window.VideoJSPlayer = class VideoJSPlayer extends Player
if data.meta.gdrive_subtitles
data.meta.gdrive_subtitles.available.forEach((subt) ->
+ label = subt.lang_original
+ if subt.name
+ label += " (#{subt.name})"
$('').attr(
src: "/gdvtt/#{data.id}/#{subt.lang}/#{subt.name}.vtt?\
vid=#{data.meta.gdrive_subtitles.vid}"
kind: 'subtitles'
srclang: subt.lang
- label: subt.name or subt.lang_original
+ label: label
).appendTo(video)
)
@@ -102,6 +105,15 @@ window.VideoJSPlayer = class VideoJSPlayer extends Player
@player.on('seeked', =>
$('.vjs-waiting').removeClass('vjs-waiting')
)
+
+ $('#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
+ )
)
)
diff --git a/www/css/cytube.css b/www/css/cytube.css
index 4fa7eed3..1f16c427 100644
--- a/www/css/cytube.css
+++ b/www/css/cytube.css
@@ -631,3 +631,7 @@ table td {
#videowrap .embed-responsive:-ms-full-screen { width: 100%; }
#videowrap .embed-responsive:-o-full-screen { width: 100%; }
#videowrap .embed-responsive:full-screen { width: 100%; }
+
+li.vjs-menu-item.vjs-selected {
+ background-color: #66a8cc !important;
+}
diff --git a/www/js/player.js b/www/js/player.js
index cd8c3927..86692898 100644
--- a/www/js/player.js
+++ b/www/js/player.js
@@ -445,7 +445,7 @@
})(Player);
sortSources = function(sources) {
- var flv, flvOrder, i, idx, len, nonflv, pref, qualities, quality, qualityOrder, sourceOrder;
+ var flv, flvOrder, idx, j, len, nonflv, pref, qualities, quality, qualityOrder, sourceOrder;
if (!sources) {
console.error('sortSources() called with null source list');
return [];
@@ -459,8 +459,8 @@
qualityOrder = qualities.slice(idx).concat(qualities.slice(0, idx));
sourceOrder = [];
flvOrder = [];
- for (i = 0, len = qualityOrder.length; i < len; i++) {
- quality = qualityOrder[i];
+ for (j = 0, len = qualityOrder.length; j < len; j++) {
+ quality = qualityOrder[j];
if (quality in sources) {
flv = [];
nonflv = [];
@@ -526,11 +526,16 @@
});
if (data.meta.gdrive_subtitles) {
data.meta.gdrive_subtitles.available.forEach(function(subt) {
+ var label;
+ label = subt.lang_original;
+ if (subt.name) {
+ label += " (" + subt.name + ")";
+ }
return $('').attr({
src: "/gdvtt/" + data.id + "/" + subt.lang + "/" + subt.name + ".vtt?vid=" + data.meta.gdrive_subtitles.vid,
kind: 'subtitles',
srclang: subt.lang,
- label: subt.name || subt.lang_original
+ label: label
}).appendTo(video);
});
}
@@ -557,9 +562,19 @@
return sendVideoUpdate();
}
});
- return _this.player.on('seeked', function() {
+ _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;
+ }
+ };
+ });
});
};
})(this));