Skip to content

Commit

Permalink
Merge pull request #547 from akadroid/master
Browse files Browse the repository at this point in the history
fix: AniList completion for external players
  • Loading branch information
ThaUnknown authored Oct 11, 2024
2 parents d023963 + 1d21f49 commit 6f953a3
Showing 1 changed file with 4 additions and 1 deletion.
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

0 comments on commit 6f953a3

Please sign in to comment.