Skip to content

Commit

Permalink
file-show: autoplay first file
Browse files Browse the repository at this point in the history
  • Loading branch information
rejetto committed Jan 24, 2025
1 parent 7205d21 commit 0e72ee5
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion frontend/src/show.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export function fileShow(entry: DirEntry, { startPlaying=false, startShuffle=fal
let onClose: any
let firstUri: string
let playMsgOnce = true
let justOpen = true
const { close } = newDialog({
noFrame: true,
className: 'file-show',
Expand Down Expand Up @@ -105,11 +106,16 @@ export function fileShow(entry: DirEntry, { startPlaying=false, startShuffle=fal
}
useEffect(() => {
const showElement = getShowElement()
if (!autoPlaying || !showElement) return
try {
if (!autoPlaying && !justOpen || !showElement) return
} finally {
justOpen = false
}
if (showElement instanceof HTMLMediaElement) {
showElement.play().catch(playFailed)
return domOn('ended', goNext, { target: showElement as any })
}
if (!autoPlaying) return // we reached here because of the justOpen, but we are not interested in images
// we are supposedly showing an image
const h = setTimeout(goNext, state.auto_play_seconds * 1000)
return () => clearTimeout(h)
Expand Down

0 comments on commit 0e72ee5

Please sign in to comment.