mirror of
https://github.com/NoCrypt/migu.git
synced 2026-03-11 17:45:32 +00:00
Merge pull request #547 from akadroid/master
fix: AniList completion for external players
This commit is contained in:
commit
6f953a3e03
1 changed files with 4 additions and 1 deletions
|
|
@ -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
|
||||
|
||||
|
|
@ -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)
|
||||
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue