This commit is contained in:
parent
a9e3cf2ea5
commit
48f62c8c02
6 changed files with 107 additions and 5 deletions
|
|
@ -99,6 +99,18 @@
|
|||
playerReady = true;
|
||||
dispatch('ready');
|
||||
|
||||
// Try to report duration early if available (some videos have it on ready)
|
||||
const storeState = $watchSync;
|
||||
const playlistItemId = storeState.currentVideo?.id;
|
||||
if (playlistItemId && playlistItemId !== durationReportedForItemId) {
|
||||
const playerDuration = player.getDuration();
|
||||
if (playerDuration > 0) {
|
||||
console.log(`Reporting duration on ready for playlist item ${playlistItemId}: ${Math.floor(playerDuration)}s`);
|
||||
watchSync.reportDuration(playlistItemId, playerDuration);
|
||||
durationReportedForItemId = playlistItemId;
|
||||
}
|
||||
}
|
||||
|
||||
// Start sync check interval
|
||||
if (syncCheckInterval) clearInterval(syncCheckInterval);
|
||||
syncCheckInterval = setInterval(checkAndSync, SYNC_CHECK_INTERVAL);
|
||||
|
|
@ -111,6 +123,8 @@
|
|||
// Always handle ENDED state - crucial for playlist advancement
|
||||
if (state === window.YT.PlayerState.ENDED) {
|
||||
dispatch('ended');
|
||||
// Also notify server directly - this is a fallback for when duration-based detection fails
|
||||
watchSync.videoEnded();
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue