Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix AniList completion for external players #547

Merged
merged 1 commit into from
Oct 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion common/views/Player/Player.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
let ended = false
let volume = Number(localStorage.getItem('volume')) || 1
let playbackRate = 1
let externalPlayerReady = false
$: localStorage.setItem('volume', (volume || 0).toString())
$: safeduration = (isFinite(duration) ? duration : currentTime) || 0

Expand Down Expand Up @@ -185,6 +186,7 @@
const duration = current.media?.media?.duration
client.removeEventListener('externalWatched', watchedListener)
watchedListener = ({ detail }) => {
externalPlayerReady = true
checkCompletionByTime(detail, duration)
}
client.on('externalWatched', watchedListener)
Expand Down Expand Up @@ -959,10 +961,11 @@

function checkCompletionByTime (currentTime, safeduration) {
const fromend = Math.max(180, safeduration / 10)
if (safeduration && currentTime && video?.readyState && safeduration - fromend < currentTime) {
if (safeduration && currentTime && (video?.readyState || externalPlayerReady) && safeduration - fromend < currentTime) {
if (media?.media?.episodes || media?.media?.nextAiringEpisode?.episode) {
if (media.media.episodes || media.media.nextAiringEpisode?.episode > media.episode) {
completed = true
externalPlayerReady = false
anilistClient.alEntry(media)
}
}
Expand Down