mirror of
https://gitea.invidious.io/iv-org/invidious-copy-2022-08-14.git
synced 2024-08-15 00:53:20 +00:00
fix: null ptr while retaining time
This commit is contained in:
parent
a18068aedf
commit
0453d08eed
1 changed files with 32 additions and 12 deletions
|
@ -59,6 +59,16 @@ videojs.Hls.xhr.beforeRequest = function(options) {
|
||||||
|
|
||||||
var player = videojs('player', options);
|
var player = videojs('player', options);
|
||||||
|
|
||||||
|
const storage = (() => {
|
||||||
|
try {
|
||||||
|
if (localStorage.length !== -1) {
|
||||||
|
return localStorage;
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.info('No storage available: ' + e);
|
||||||
|
}
|
||||||
|
return undefined;
|
||||||
|
})();
|
||||||
|
|
||||||
if (location.pathname.startsWith('/embed/')) {
|
if (location.pathname.startsWith('/embed/')) {
|
||||||
player.overlay({
|
player.overlay({
|
||||||
|
@ -386,25 +396,35 @@ function get_video_time() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function set_all_video_times(times) {
|
function set_all_video_times(times) {
|
||||||
const json = JSON.stringify(times);
|
if (storage) {
|
||||||
|
if (times) {
|
||||||
localStorage.setItem(save_player_pos_key, json);
|
try {
|
||||||
|
storage.setItem(save_player_pos_key, JSON.stringify(times));
|
||||||
|
} catch (e) {
|
||||||
|
console.debug('set_all_video_times: ' + e);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
storage.removeItem(save_player_pos_key);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_all_video_times() {
|
function get_all_video_times() {
|
||||||
|
if (storage) {
|
||||||
|
const raw = storage.getItem(save_player_pos_key);
|
||||||
|
if (raw !== null) {
|
||||||
try {
|
try {
|
||||||
const raw = localStorage.getItem(save_player_pos_key);
|
return JSON.parse(raw);
|
||||||
const times = JSON.parse(raw);
|
} catch (e) {
|
||||||
|
console.debug('get_all_video_times: ' + e);
|
||||||
return times || {};
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch {
|
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
function remove_all_video_times() {
|
function remove_all_video_times() {
|
||||||
localStorage.removeItem(save_player_pos_key);
|
set_all_video_times(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
function set_time_percent(percent) {
|
function set_time_percent(percent) {
|
||||||
|
|
Loading…
Reference in a new issue