diff --git a/css/player-base.js b/css/player-base.js index 7f657310..1c898161 100644 --- a/css/player-base.js +++ b/css/player-base.js @@ -1,7 +1,7 @@ // in the beginning.... god made mrrprpmnaynayaynaynayanyuwuuuwmauwnwanwaumawp :p var _yt_player = videojs; -document.addEventListener("DOMContentLoaded", () => { - // video.js 8 init - source can be seen in https://poketube.fun/static/vjs.min.js or the vjs.min.js file + document.addEventListener("DOMContentLoaded", () => { + // video.js 8 init - source can be seen in https://poketube.fun/static/vjs.min.js or the vjs.min.js file const video = videojs('video', { controls: true, autoplay: false, @@ -9,27 +9,54 @@ document.addEventListener("DOMContentLoaded", () => { }); // todo : remove this code lol - const qua = new URLSearchParams(window.location.search).get("quality") || ""; - const vidKey = new URLSearchParams(window.location.search).get('v'); - localStorage.setItem(`progress-${vidKey}`, 0); + const qs = new URLSearchParams(window.location.search); + const qua = qs.get("quality") || ""; + const vidKey = qs.get('v'); + try { localStorage.setItem(`progress-${vidKey}`, 0); } catch {} // raw media elements const videoEl = document.getElementById('video'); const audio = document.getElementById('aud'); - const audioSrc = audio.getAttribute('src'); - const vidSrcObj = video.src(); - const videoSrc = Array.isArray(vidSrcObj) ? (vidSrcObj[0] && vidSrcObj[0].src) : vidSrcObj; + // resolve initial sources robustly (works whether