fix: display all shaka errors in UI

closes #176
This commit is contained in:
Shiny Nematoda 2025-03-19 07:23:37 +00:00
parent 05b40b6782
commit aca1ce3bb7

View file

@ -14,6 +14,11 @@ const player = usePlayer(),
const audio = ref(null);
const dataOf = Object.freeze({
1002: 1,
3016: 0,
});
function audioCanPlay() {
player.state.status = 'pause';
audio.value.play().catch(err => {
@ -43,6 +48,7 @@ async function Stream() {
codecs = store.getItem('codec');
await audioPlayer.attach(audio.value);
audioPlayer.addEventListener('error', ({ detail }) => errorLog(detail));
for (const [playerKey, audioKey] of Object.entries({
rate: 'playbackRate',
@ -123,11 +129,12 @@ async function Stream() {
);
}
})
.catch(err => {
.catch(errorLog);
}
function errorLog(err) {
a.add(err.data[dataOf[err.code]] ?? 'Shaka Error: ' + err.code);
console.error(err);
if (err.code == 3016) a.add('MediaError: ' + err.data[0]);
else a.add('Error: ' + err.code);
});
}
function destroy() {