mirror of
https://github.com/iv-org/invidious.git
synced 2025-10-29 11:41:58 +00:00
Use markers to implement timestamps
This commit is contained in:
@@ -200,13 +200,20 @@ if (!video_data.params.listen && video_data.vr && video_data.params.vr_mode) {
|
||||
// Add markers
|
||||
if (video_data.params.video_start > 0 || video_data.params.video_end > 0) {
|
||||
var markers = [{ time: video_data.params.video_start, text: 'Start' }];
|
||||
|
||||
if (video_data.params.video_end < 0) {
|
||||
markers.push({ time: video_data.length_seconds - 0.5, text: 'End' });
|
||||
} else {
|
||||
markers.push({ time: video_data.params.video_end, text: 'End' });
|
||||
if (video_data.starting_timestamp_seconds) {
|
||||
markers = [{ time: video_data.starting_timestamp_seconds, text: 'Start' }];
|
||||
}
|
||||
|
||||
if (!video_data.ending_timestamp_seconds) {
|
||||
if (video_data.params.video_end < 0) {
|
||||
markers.push({ time: video_data.length_seconds - 0.5, text: 'End' });
|
||||
} else {
|
||||
markers.push({ time: video_data.params.video_end, text: 'End' });
|
||||
}
|
||||
} else {
|
||||
markers.push({ time: video_data.ending_timestamp_seconds, text: 'End' });
|
||||
}
|
||||
|
||||
player.markers({
|
||||
onMarkerReached: function (marker) {
|
||||
if (marker.text === 'End')
|
||||
|
||||
@@ -103,7 +103,7 @@ function continue_autoplay(event) {
|
||||
}
|
||||
|
||||
function get_compilation(compid) {
|
||||
var compilation = document.getElementById('compilations');
|
||||
var compilation = document.getElementById('compilation');
|
||||
|
||||
compilation.innerHTML = spinnerHTMLwithHR;
|
||||
|
||||
@@ -111,47 +111,49 @@ function get_compilation(compid) {
|
||||
compid_url = '/api/v1/compilations/' + compid +
|
||||
'?index=' + video_data.index +
|
||||
'&continuation=' + video_data.id +
|
||||
'&format=html&hl=' + video_data.preferences.locale;
|
||||
'&format=html&hl=' + video_data.preferences.locale;
|
||||
|
||||
console.log("Send "+compid_url);
|
||||
|
||||
helpers.xhr('GET', compid_url, {retries: 5, entity_name: 'compilation'}, {
|
||||
on200: function (response) {
|
||||
compilation.innerHTML = response.compilationHtml;
|
||||
|
||||
if (!response.nextVideo) return;
|
||||
if (!response.nextVideo) return;
|
||||
|
||||
var nextVideo = document.getElementById(response.nextVideo);
|
||||
nextVideo.parentNode.parentNode.scrollTop = nextVideo.offsetTop;
|
||||
var nextVideo = document.getElementById(response.nextVideo);
|
||||
nextVideo.parentNode.parentNode.scrollTop = nextVideo.offsetTop;
|
||||
|
||||
player.on('ended', function () {
|
||||
var url = new URL('https://example.com/watch?v=' + response.nextVideo);
|
||||
player.on('ended', function () {
|
||||
var url = new URL('https://example.com/watch?v=' + response.nextVideo);
|
||||
|
||||
url.searchParams.set('list', compid);
|
||||
if (!plid.startsWith('RD'))
|
||||
url.searchParams.set('index', response.index);
|
||||
if (video_data.params.autoplay || video_data.params.continue_autoplay)
|
||||
url.searchParams.set('autoplay', '1');
|
||||
if (video_data.params.listen !== video_data.preferences.listen)
|
||||
url.searchParams.set('listen', video_data.params.listen);
|
||||
if (video_data.params.speed !== video_data.preferences.speed)
|
||||
url.searchParams.set('speed', video_data.params.speed);
|
||||
if (video_data.params.local !== video_data.preferences.local)
|
||||
url.searchParams.set('local', video_data.params.local);
|
||||
url.searchParams.set('list', compid);
|
||||
if (!compid.startsWith('RD'))
|
||||
url.searchParams.set('index', response.index);
|
||||
if (video_data.params.autoplay || video_data.params.continue_autoplay)
|
||||
url.searchParams.set('autoplay', '1');
|
||||
if (video_data.params.listen !== video_data.preferences.listen)
|
||||
url.searchParams.set('listen', video_data.params.listen);
|
||||
if (video_data.params.speed !== video_data.preferences.speed)
|
||||
url.searchParams.set('speed', video_data.params.speed);
|
||||
if (video_data.params.local !== video_data.preferences.local)
|
||||
url.searchParams.set('local', video_data.params.local);
|
||||
|
||||
location.assign(url.pathname + url.search);
|
||||
});
|
||||
},
|
||||
onNon200: function (xhr) {
|
||||
compilation.innerHTML = '';
|
||||
document.getElementById('continue').style.display = '';
|
||||
},
|
||||
onError: function (xhr) {
|
||||
compilation.innerHTML = spinnerHTMLwithHR;
|
||||
},
|
||||
onTimeout: function (xhr) {
|
||||
compilation.innerHTML = spinnerHTMLwithHR;
|
||||
}
|
||||
});
|
||||
}
|
||||
location.assign(url.pathname + url.search);
|
||||
});
|
||||
},
|
||||
onNon200: function (xhr) {
|
||||
compilation.innerHTML = '';
|
||||
document.getElementById('continue').style.display = '';
|
||||
},
|
||||
onError: function (xhr) {
|
||||
compilation.innerHTML = spinnerHTMLwithHR;
|
||||
},
|
||||
onTimeout: function (xhr) {
|
||||
compilation.innerHTML = spinnerHTMLwithHR;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function get_playlist(plid) {
|
||||
var playlist = document.getElementById('playlist');
|
||||
|
||||
Reference in New Issue
Block a user