Minor fixes for Google Drive subtitles

This commit is contained in:
calzoneman 2015-07-26 12:28:43 -07:00
parent 4a0cbce575
commit f12397db23
3 changed files with 37 additions and 6 deletions

View file

@ -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})"
$('<track/>').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
)
)
)