diff --git a/thrimbletrimmer/dashboard.html b/thrimbletrimmer/dashboard.html index eb67a70..c3d4f5c 100644 --- a/thrimbletrimmer/dashboard.html +++ b/thrimbletrimmer/dashboard.html @@ -50,7 +50,6 @@ + diff --git a/thrimbletrimmer/index.html b/thrimbletrimmer/index.html index aafb4b3..be0df2a 100644 --- a/thrimbletrimmer/index.html +++ b/thrimbletrimmer/index.html @@ -27,7 +27,6 @@
Start Time
- @@ -36,7 +35,6 @@ - @@ -45,9 +43,8 @@ - - - + +
Wubloader URL Stream Start Time End Time
WubloadersStreamsHoursStreamsHours UTC Bustime diff --git a/thrimbletrimmer/scripts/IO.js b/thrimbletrimmer/scripts/IO.js index d6d7cc4..b4587b2 100644 --- a/thrimbletrimmer/scripts/IO.js +++ b/thrimbletrimmer/scripts/IO.js @@ -13,13 +13,15 @@ pageSetup = function() { } //data = testThrimShim; document.getElementById("hiddenSubmissionID").value = data.id; + document.getElementById("StreamName").value = data.video_channel ? data.video_channel:document.getElementById("StreamName").value; document.getElementById("StreamStart").value = data.event_start; document.getElementById("BusTimeStart").value = (new Date(data.event_start+"Z") < desertBusStart ? "-":"") + videojs.formatTime(Math.abs((new Date(data.event_start+"Z") - desertBusStart)/1000), 600.01); document.getElementById("StreamEnd").value = data.event_end; document.getElementById("BusTimeEnd").value = (new Date(data.event_end+"Z") < desertBusStart ? "-":"") + videojs.formatTime(Math.abs((new Date(data.event_end+"Z") - desertBusStart)/1000), 600.01); document.getElementById("VideoTitle").value = data.video_title; document.getElementById("VideoDescription").value = data.video_description ? data.video_description:data.description; - loadPlaylist(); + + loadPlaylist(data.video_start, data.video_end); }); } else { @@ -33,8 +35,8 @@ pageSetup = function() { } }; -loadPlaylist = function() { - var playlist = document.getElementById("WubloaderLocation").value + "/playlist/" + document.getElementById("StreamName").value + ".m3u8"; +loadPlaylist = function(startTrim, endTrim) { + var playlist = "/playlist/" + document.getElementById("StreamName").value + ".m3u8"; if(document.getElementById("BusTimeToggleBus").checked) { var streamStart = desertBusStart; @@ -53,11 +55,11 @@ loadPlaylist = function() { var streamEnd = document.getElementById("StreamEnd").value ? "end="+document.getElementById("StreamEnd").value:null; var queryString = (streamStart || streamEnd) ? "?" + [streamStart, streamEnd].filter((a) => !!a).join("&"):""; - setupPlayer(playlist + queryString); + setupPlayer(playlist + queryString, startTrim, endTrim); //Get quality levels for advanced properties. document.getElementById('qualityLevel').innerHTML = ""; - fetch(document.getElementById('WubloaderLocation').value + '/files/' + document.getElementById('StreamName').value).then(data => data.json()).then(function (data) { // {mode: 'cors'} ??? + fetch('/files/' + document.getElementById('StreamName').value).then(data => data.json()).then(function (data) { // {mode: 'cors'} ??? if (!data.length) { console.log("Could not retrieve quality levels"); return; @@ -119,8 +121,7 @@ thrimbletrimmerDownload = function() { var downloadStart = getRealTimeForPlayerTime(discontinuities, player.trimmingControls().options.startTrim); var downloadEnd = getRealTimeForPlayerTime(discontinuities, player.trimmingControls().options.endTrim); - var targetURL = document.getElementById("WubloaderLocation").value + - "/cut/" + document.getElementById("StreamName").value + + var targetURL = "/cut/" + document.getElementById("StreamName").value + "/"+document.getElementById('qualityLevel').options[document.getElementById('qualityLevel').options.selectedIndex].value+".ts" + "?start=" + downloadStart + "&end=" + downloadEnd + diff --git a/thrimbletrimmer/scripts/playerSetup.js b/thrimbletrimmer/scripts/playerSetup.js index 5c0f2ea..d9c76d9 100644 --- a/thrimbletrimmer/scripts/playerSetup.js +++ b/thrimbletrimmer/scripts/playerSetup.js @@ -39,7 +39,10 @@ function setupPlayer(source, startTrim, endTrim) { this.vhs.playlists.on('loadedmetadata', function() { // setTimeout(function() { player.play(); }, 1000); player.hasStarted(true); //So it displays all the controls. - var trimmingControls = player.trimmingControls({ startTrim:(startTrim ? startTrim:0), endTrim:(endTrim ? endTrim:player.duration()) }); + stream_start = player.vhs.playlists.master.playlists.filter(playlist => typeof playlist.discontinuityStarts !== "undefined")[0].dateTimeObject; + startTrim = startTrim ? (new Date(startTrim+"Z")-stream_start)/1000:0; + endTrim = endTrim ? (new Date(endTrim+"Z")-stream_start)/1000:player.duration(); + var trimmingControls = player.trimmingControls({ startTrim:startTrim, endTrim:endTrim }); }); // How about an event listener?