Skip to content

Commit

Permalink
📺 Video preview controls output if playing
Browse files Browse the repository at this point in the history
- Fixed video slider time set to 0 sometimes if paused
- Fixed audio playlist looping sometimes when it should not
- Fixed next after media finished not working for multiple outputs
- Fixed output style adding template textbox when slide has none
  • Loading branch information
vassbo committed Dec 10, 2024
1 parent 2543e0b commit d8d6980
Show file tree
Hide file tree
Showing 8 changed files with 135 additions and 74 deletions.
4 changes: 2 additions & 2 deletions public/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@
"import": "Import",
"songbeamer_import": "Songbeamer Import",
"export": "Export",
"importing": "Importing",
"importing": "Importing...",
"import_scripture": "Import scripture",
"player": "Player",
"edit_event": "Edit event",
Expand Down Expand Up @@ -737,7 +737,7 @@
"export": {
"export": "Export",
"export_as": "Export {} as",
"exporting": "Exporting",
"exporting": "Exporting...",
"exported": "Exported!",
"oneFile": "One file",
"selected_shows": "Selected shows",
Expand Down
3 changes: 2 additions & 1 deletion src/frontend/components/helpers/audio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,8 @@ function getPlayingAudio() {
get(playingAudio)[audioPath].audio.currentTime = 0
get(playingAudio)[audioPath].audio.play()
} else if (get(activePlaylist)?.active === audioPath) {
let playlist = get(audioPlaylists)[audioPath] || {}
let playlistId = get(activePlaylist).id || ""
let playlist = get(audioPlaylists)[playlistId] || {}

playingAudio.update((a: any) => {
a[audioPath]?.audio?.pause()
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/components/helpers/output.ts
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ export function getCurrentMediaTransition() {
// TEMPLATE

export function mergeWithTemplate(slideItems: Item[], templateItems: Item[], addOverflowTemplateItems: boolean = false, resetAutoSize: boolean = true) {
if (!slideItems) return []
if (!slideItems?.length) return []
slideItems = clone(slideItems)

if (!templateItems.length) return slideItems
Expand Down
8 changes: 4 additions & 4 deletions src/frontend/components/helpers/showActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -798,13 +798,13 @@ export function playNextGroup(globalGroupIds: string[], { showRef, outSlide, cur
}

// go to next slide if current output slide has nextAfterMedia action
let nextActive = false
let nextActive: string[] = []
export function checkNextAfterMedia(endedId: string, type: "media" | "audio" | "timer" = "media", outputId: string = "") {
if (nextActive) return false
if (nextActive.includes(outputId)) return false

nextActive = true
nextActive.push(outputId)
setTimeout(() => {
nextActive = false
nextActive.splice(nextActive.indexOf(outputId), 1)
}, 600) // MAKE SURE NEXT SLIDE HAS TRANSITIONED

if (!outputId) outputId = getActiveOutputs(get(outputs), true, true, true)[0]
Expand Down
9 changes: 8 additions & 1 deletion src/frontend/components/output/VideoSlider.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
export let activeOutputIds: string[] = []
export let unmutedId: string = ""
export let toOutput: boolean = false
export let big: boolean = false
export let disabled: boolean = false
export let changeValue: number = 0
Expand Down Expand Up @@ -103,7 +104,7 @@
}}
/>

<div class="main">
<div class="main" class:big>
{#if hover}
<span>
{time}
Expand Down Expand Up @@ -146,6 +147,9 @@
margin: 0 5px;
font-size: 0.8em;
}
.main.big {
font-size: 1em;
}
.slider {
flex: 1;
Expand All @@ -154,4 +158,7 @@
display: flex;
align-items: center;
}
.main.big .slider {
margin: 0 10px;
}
</style>
39 changes: 25 additions & 14 deletions src/frontend/components/output/tools/MediaControls.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
export let currentOutput: any
export let outputId: string
export let big: boolean = false
$: videoData = $videosData[outputId] || {}
Expand All @@ -26,6 +27,7 @@
// custom time update (for player videos)
onMount(() => {
if ($videosTime[outputId]) videoTime = $videosTime[outputId]
setInterval(() => {
if (videoData.paused || timeJustUpdated) return
videoTime++
Expand Down Expand Up @@ -89,21 +91,23 @@
<svelte:window on:keydown={keydown} />

{#if background}
<span class="name" on:click={openPreview}>
{#if background?.type === "player"}
<p>{$playerVideos[background?.id || ""]?.name || ""}</p>
{:else}
<p>{mediaName}</p>
{/if}
</span>
{#if !big}
<span class="name" on:click={openPreview}>
{#if background?.type === "player"}
<p>{$playerVideos[background?.id || ""]?.name || ""}</p>
{:else}
<p>{mediaName}</p>
{/if}
</span>
{/if}

{#if type === "video" || background?.type === "player"}
<span class="group">
<span class="group" class:big>
<Button center title={videoData.paused ? $dictionary.media?.play : $dictionary.media?.pause} disabled={$outLocked} on:click={playPause}>
<Icon id={videoData.paused ? "play" : "pause"} white={videoData.paused} size={1.2} />
<Icon id={videoData.paused ? "play" : "pause"} white={videoData.paused} size={big ? 1.7 : 1.2} />
</Button>

<VideoSlider disabled={$outLocked} {activeOutputIds} bind:videoData bind:videoTime bind:changeValue unmutedId={outputId} toOutput />
<VideoSlider disabled={$outLocked} {activeOutputIds} bind:videoData bind:videoTime bind:changeValue unmutedId={outputId} toOutput big />

<Button
center
Expand All @@ -112,7 +116,7 @@
changeValue = Math.max(videoTime - 10, 0.01)
}}
>
<Icon id="back_10" white size={1.2} />
<Icon id="back_10" white size={big ? 1.4 : 1.2} />
</Button>
<Button
center
Expand All @@ -121,7 +125,7 @@
changeValue = Math.min(videoTime + 10, videoData.duration - 0.1)
}}
>
<Icon id="forward_10" white size={1.2} />
<Icon id="forward_10" white size={big ? 1.4 : 1.2} />
</Button>
<Button
center
Expand All @@ -131,7 +135,7 @@
sendToOutput()
}}
>
<Icon id="loop" white={!videoData.loop} size={1.2} />
<Icon id="loop" white={!videoData.loop} size={big ? 1.4 : 1.2} />
</Button>
<Button
center
Expand All @@ -143,7 +147,7 @@
sendToOutput()
}}
>
<Icon id={videoData.muted === false ? "volume" : "muted"} white={videoData.muted !== false} size={1.2} />
<Icon id={videoData.muted === false ? "volume" : "muted"} white={videoData.muted !== false} size={big ? 1.4 : 1.2} />
</Button>
</span>
{/if}
Expand All @@ -159,6 +163,13 @@
padding: 0.3em !important;
}
.group.big {
background-color: var(--primary-darkest);
}
.group.big :global(.slider input) {
background-color: var(--primary);
}
.name {
display: flex;
justify-content: center;
Expand Down
Loading

0 comments on commit d8d6980

Please sign in to comment.