fix: null ptr while retaining time

pull/2744/head
Théo Gaillard 2021-12-26 13:45:27 +01:00
rodzic a18068aedf
commit 0453d08eed
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 9C6AAAF893B070FC
1 zmienionych plików z 32 dodań i 12 usunięć

Wyświetl plik

@ -59,6 +59,16 @@ videojs.Hls.xhr.beforeRequest = function(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/')) {
player.overlay({
@ -386,25 +396,35 @@ function get_video_time() {
}
function set_all_video_times(times) {
const json = JSON.stringify(times);
localStorage.setItem(save_player_pos_key, json);
if (storage) {
if (times) {
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() {
try {
const raw = localStorage.getItem(save_player_pos_key);
const times = JSON.parse(raw);
return times || {};
}
catch {
return {};
if (storage) {
const raw = storage.getItem(save_player_pos_key);
if (raw !== null) {
try {
return JSON.parse(raw);
} catch (e) {
console.debug('get_all_video_times: ' + e);
}
}
}
return {};
}
function remove_all_video_times() {
localStorage.removeItem(save_player_pos_key);
set_all_video_times(null);
}
function set_time_percent(percent) {