add error notices :3

This commit is contained in:
ashley 2024-07-05 13:59:13 +00:00
parent 8d60655fa7
commit 5be52a9d7b

View file

@ -671,13 +671,16 @@ background-color: #0000;
html:fullscreen *:not(html, video, body, ptd-app-ejs, .app, .watch-page, .primary, .video-player-container, #popupMenu, #popupMenu *) {
visibility: hidden !important;
}
#nojs-high-res-warning {
.error-card {
background-color: #823434aa;
margin: 30px;
padding: 5px 20px;
border: 2px solid red;
border-radius: 10px;
}
#buffer-failed-warning {
display: none;
}
.rainbow-gradient {
background: linear-gradient(to right, red, orange, yellow, green, blue, indigo, violet);
@ -709,6 +712,31 @@ background-color: #0000;
secs.toString().padStart(2, '0');
}
return timeString;
}
function showErrorCard(e) {
try {
switch (e.target.error.code) {
case e.target.error.MEDIA_ERR_ABORTED:
return;
break;
case e.target.error.MEDIA_ERR_NETWORK:
document.querySelector("div p span").innerText = "(Network error)"
break;
case e.target.error.MEDIA_ERR_DECODE:
document.querySelector("div p span").innerText = "(Decode error/lack of browser support)"
break;
case e.target.error.MEDIA_ERR_SRC_NOT_SUPPORTED:
document.querySelector("div p span").innerText = "(Network error or format not supported)"
break;
default:
document.querySelector("div p span").innerText = "(Unknown error)"
break;
}
}
catch {
document.querySelector("div p span").innerText = "(Network error)"
}
document.getElementById("buffer-failed-warning").style.display = "block";
}
document.addEventListener("DOMContentLoaded", () => {
//FIXME: saved playback intentionally overwritten
@ -760,6 +788,15 @@ background-color: #0000;
}, 800)
}
}, 1000)
setInterval(() => {
if(Math.round(video.currentTime) != Math.round(aud.currentTime)) {
video.pause(); aud.pause(); playPauseButton.innerHTML = playSVG;
video.currentTime > aud.currentTime ? aud.currentTime = video.currentTime : video.currentTime = aud.currentTime;
setTimeout(() => {
video.play(); aud.play(); playPauseButton.innerHTML = pauseSVG;
}, 800)
}
}, 1000)
video.addEventListener("click", toggleVideo);
video.addEventListener("dblclick", () => {
document.documentElement.requestFullscreen();
@ -1252,19 +1289,28 @@ Offical Discord Server! :3
<% if (!qua) { //TODO - a %>
<audio id="aud" preload>
<source src="<%=u%>/latest_version?id=<%=inv_vid.videoId%>&itag=140&local=true" type="video/mp4"/>
<source src="<%=u%>/latest_version?id=<%=inv_vid.videoId%>&itag=140&local=true" type="video/mp4" onerror="showErrorCard(event)"/>
</audio>
<% } else { %>
<audio id="aud"></audio>
<% } %>
<noscript>
<% if (!qua) { %>
<div id="nojs-high-res-warning">
<div id="nojs-high-res-warning" class="error-card">
<p>Due to YouTube's recent changes on high resolution playback, it is sadly impossible to play high-resolution video with audio without client-side JavaScript enabled. Switch to SD quality or enable JavaScript to play your video with audio.</p>
</div>
<% } %>
</noscript>
<video class="player video-ambient-container" id="video" style="border-radius: 16px; box-sizing: border-box; min-width: 100%; display: block;" preload>
<div id="buffer-failed-warning" class="error-card">
<p>
Oh no, the video couldn't be loaded :(
<br/>
You can try refreshing the page!
<br/>
<span></span>
</p>
</div>
<video class="player video-ambient-container" id="video" style="border-radius: 16px; box-sizing: border-box; min-width: 100%; display: block;" preload onerror="showErrorCard(event)">
<% if (isvidious) { %>
<% if (!qua) { %>
<%
@ -1275,30 +1321,30 @@ Offical Discord Server! :3
}
});
%>
<source src="<%=u%>/latest_version?id=<%=inv_vid.videoId%>&itag=<%=itag%>&local=true" type="video/mp4; codecs=&quot;avc1.64001F, mp4a.40.2&quot;" label="hd720" selected="true">
<source src="<%=u%>/latest_version?id=<%=inv_vid.videoId%>&itag=<%=itag%>&local=true" type="video/mp4; codecs=&quot;avc1.64001F, mp4a.40.2&quot;" label="hd720" selected="true" onerror="showErrorCard(event)">
<% } %>
<% if (qua === "medium") { %>
<source src="<%=u%>/latest_version?id=<%=inv_vid.videoId%>&itag=18&local=true" type="video/mp4; codecs=&quot;avc1.64001F, mp4a.40.2&quot;" label="sd360" selected="true">
<source src="<%=u%>/latest_version?id=<%=inv_vid.videoId%>&itag=18&local=true" type="video/mp4; codecs=&quot;avc1.64001F, mp4a.40.2&quot;" label="sd360" selected="true" onerror="showErrorCard(event)">
<% } %>
<% } %>
<% if (!isSchoolProxy) { %>
<% if (!isvidious) { %>
<% if (!qua) { %>
<source src="https://tube.kuylar.dev/proxy/media/<%=inv_vid.videoId%>/22" type="video/mp4; codecs=&quot;avc1.64001F, mp4a.40.2&quot;" label="hd720" selected="true">
<source src="https://tube.kuylar.dev/proxy/media/<%=inv_vid.videoId%>/22" type="video/mp4; codecs=&quot;avc1.64001F, mp4a.40.2&quot;" label="hd720" selected="true" onerror="showErrorCard(event)">
<% } %>
<% if (qua === "medium") { %>
<source src="https://tube.kuylar.dev/proxy/media/<%=inv_vid.videoId%>/18" type="video/mp4; codecs=&quot;avc1.64001F, mp4a.40.2&quot;" label="sd360" selected="true">
<source src="https://tube.kuylar.dev/proxy/media/<%=inv_vid.videoId%>/18" type="video/mp4; codecs=&quot;avc1.64001F, mp4a.40.2&quot;" label="sd360" selected="true" onerror="showErrorCard(event)">
<% } %>
<% } %>
<% } %>
<% if (isSchoolProxy) { %>
<% if (!qua) { %>
<source src="https://tube-proxy.ashley0143.xyz/proxy/media/<%=inv_vid.videoId%>/22" type="video/mp4; codecs=&quot;avc1.64001F, mp4a.40.2&quot;" label="hd720" selected="true">
<source src="https://tube-proxy.ashley0143.xyz/proxy/media/<%=inv_vid.videoId%>/22" type="video/mp4; codecs=&quot;avc1.64001F, mp4a.40.2&quot;" label="hd720" selected="true" onerror="showErrorCard()">
<% } %>
<% if (qua === "medium") { %>
<source src="https://tube-proxy.ashley0143.xyz/proxy/media/<%=inv_vid.videoId%>/18" type="video/mp4; codecs=&quot;avc1.64001F, mp4a.40.2&quot;" label="sd360" selected="true">
<source src="https://tube-proxy.ashley0143.xyz/proxy/media/<%=inv_vid.videoId%>/18" type="video/mp4; codecs=&quot;avc1.64001F, mp4a.40.2&quot;" label="sd360" selected="true" onerror="showErrorCard()">
<% } %>
<% } %>