Compare commits

...

2 Commits

Author SHA1 Message Date
Erik Thuning
f0b3b19598 Added very rudimentary support for packages with multiple subtitle files,
treating the first subs file as the only file so the button can remain a toggle
2022-12-08 14:16:36 +01:00
Erik Thuning
d5cb2021cf presentation.sources is now expected to be an object instead of a list 2022-11-30 11:16:38 +01:00

@ -32,7 +32,8 @@ function init() {
var mainstream = document.querySelector('.main > video')
// A bit too magic with all the [0] but what can you do...
var defaultres = Object.keys(presentation.sources[0].video)[0]
var defaultres = Object.keys(
Object.values(presentation.sources)[0].video)[0]
if('resolution' in cookies) {
defaultres = cookies.resolution
@ -77,7 +78,7 @@ function init() {
setupFullscreen()
setupCopying(mainstream)
setupVolume(mainstream, cookies.volume, cookies.mute)
setupResSwitching(presentation.sources, defaultres)
setupResSwitching(Object.values(presentation.sources), defaultres)
setupSwitching(mainstream)
setupSync(mainstream)
setupPlayback(body, mainstream)
@ -198,13 +199,13 @@ function swapText(element) {
}
function loadStreams(presentation, mainstream, defaultres) {
var streamlist = presentation.sources
var streamlist = Object.values(presentation.sources)
var token = presentation.token
var mainparent = mainstream.parentNode
var template = document.getElementById('stream-template')
var main = streamlist[0]
if(typeof main.video === "string") {
mainstream.src = main.video +"?token="+ token
} else {
@ -654,10 +655,14 @@ function setupSubs(subs, subCookie, accessToken) {
button.parentNode.removeChild(button)
return
}
var subsName = Object.keys(subs)[0]
var subsFile = subs[subsName]
document.querySelectorAll('video').forEach(function(stream) {
var subtrack = document.createElement('track')
subtrack.kind = 'subtitles'
subtrack.src = subs + '?token=' + accessToken
subtrack.src = subsFile + '?token=' + accessToken
stream.appendChild(subtrack)
})