feat: add error handling to player episode functions
This commit is contained in:
@@ -29,8 +29,9 @@ export const completeAnime = async (episodeNumber: number): Promise<void> => {
|
|||||||
caret.textContent = "▾";
|
caret.textContent = "▾";
|
||||||
trigger.appendChild(caret);
|
trigger.appendChild(caret);
|
||||||
}
|
}
|
||||||
} catch {
|
} catch (error) {
|
||||||
state.episode.completionSent = false;
|
state.episode.completionSent = false;
|
||||||
|
console.error("failed to complete anime:", error);
|
||||||
if (state.episode.completionAttempts < 2) {
|
if (state.episode.completionAttempts < 2) {
|
||||||
state.episode.completionAttempts++;
|
state.episode.completionAttempts++;
|
||||||
setTimeout(() => completeAnime(episodeNumber), 1000);
|
setTimeout(() => completeAnime(episodeNumber), 1000);
|
||||||
|
|||||||
@@ -93,7 +93,9 @@ export const goToNextEpisode = async (): Promise<void> => {
|
|||||||
const nextSourceURL = `${state.playback.streamURL}?mode=${encodeURIComponent(fallback)}&token=${encodeURIComponent(source.token)}${source.type === "m3u8" ? "&hls=1" : ""}${preferredQuality !== "best" ? `&quality=${encodeURIComponent(preferredQuality)}` : ""}`;
|
const nextSourceURL = `${state.playback.streamURL}?mode=${encodeURIComponent(fallback)}&token=${encodeURIComponent(source.token)}${source.type === "m3u8" ? "&hls=1" : ""}${preferredQuality !== "best" ? `&quality=${encodeURIComponent(preferredQuality)}` : ""}`;
|
||||||
loadVideoSource(nextSourceURL, source.type);
|
loadVideoSource(nextSourceURL, source.type);
|
||||||
if (!state.elements.video.paused) {
|
if (!state.elements.video.paused) {
|
||||||
state.elements.video.play().catch(() => undefined);
|
state.elements.video.play().catch((error) => {
|
||||||
|
console.debug("failed to play video:", error);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
state.playback.pendingSeekTime = null;
|
state.playback.pendingSeekTime = null;
|
||||||
@@ -137,7 +139,8 @@ export const goToNextEpisode = async (): Promise<void> => {
|
|||||||
const url = new URL(window.location.href);
|
const url = new URL(window.location.href);
|
||||||
url.searchParams.set("ep", String(nextEp));
|
url.searchParams.set("ep", String(nextEp));
|
||||||
history.pushState(null, "", url.toString());
|
history.pushState(null, "", url.toString());
|
||||||
} catch {
|
} catch (error) {
|
||||||
|
console.error("failed to update url:", error);
|
||||||
fallbackToEpisodeNavigation(nextEp);
|
fallbackToEpisodeNavigation(nextEp);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -43,7 +43,8 @@ export const setupThumbnails = (): void => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch((error) => {
|
||||||
window.showToast?.({ message: "Failed to load episode thumbnails." });
|
window.showToast?.({ message: "Failed to load episode thumbnails." });
|
||||||
|
console.error("failed to load episode thumbnails:", error);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user