Skip to content

Commit

Permalink
Expose reload playlist, tweak regeneration code
Browse files Browse the repository at this point in the history
  • Loading branch information
dtcooper committed Jul 29, 2024
1 parent 7348695 commit d3b0322
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 12 deletions.
33 changes: 30 additions & 3 deletions client/src/main/Player.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import { config, userConfig } from "../stores/config"
import { singlePlayRotators, stop as stopSinglePlayRotator } from "../stores/single-play-rotators"
import { db } from "../stores/db"
import { log } from "../stores/client-logs"
import { Wait } from "../stores/player"
import { setLED, LED_OFF } from "../stores/midi"
Expand Down Expand Up @@ -109,8 +110,23 @@
// Skip all callbacks and logging
item.done(true, true)
}
updateUI()
// Regenerate stopsets
let numStopsetsToAdd = Math.max($config.STOPSET_PRELOAD_COUNT, 1)
// If current item is a stopset
if (items.length === 1 && items[0].type === "stopset") {
const item = items[0]
// If it's playing, generate one less than needed
if (item.startedPlaying) {
numStopsetsToAdd--
} else {
// If it's not playing, remove it
items.pop()
item.done(true, true)
}
}
while (numStopsetsToAdd-- > 0) {
addStopset()
}
Expand All @@ -120,8 +136,9 @@
const regenerateNextStopset = () => {
let nextStopset
for (nextStopset = 1; nextStopset < items.length; nextStopset++) {
if (items[nextStopset].type === "stopset") {
for (nextStopset = 0; nextStopset < items.length; nextStopset++) {
// Find the first non-playing stopset
if (items[nextStopset].type === "stopset" && !items[nextStopset].startedPlaying) {
break
}
}
Expand Down Expand Up @@ -222,7 +239,17 @@
{#if items.length > 0}
{@const item = items[0]}

<PlayButtons {items} {pause} {play} {skip} {regenerateNextStopset} {skipCurrentStopset} {overdue} {overtime} />
<PlayButtons
{items}
{pause}
{play}
{skip}
{regenerateNextStopset}
{reloadPlaylist}
{skipCurrentStopset}
{overdue}
{overtime}
/>
<PlayBar {item} />
{:else}
<div class="mt-3 text-center text-xl italic text-error">
Expand Down
26 changes: 18 additions & 8 deletions client/src/main/player/Buttons.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import skipNextCircleOutline from "@iconify/icons-mdi/skip-next-circle-outline"
import skipForwardOutlineIcon from "@iconify/icons-mdi/skip-forward-outline"
import reloadIcon from "@iconify/icons-mdi/reload"
import reloadAlertIcon from "@iconify/icons-mdi/reload-alert"
import { userConfig } from "../../stores/config"
import { blockSpacebarPlay } from "../../stores/player"
Expand All @@ -27,6 +28,7 @@
export let skip
export let skipCurrentStopset
export let regenerateNextStopset
export let reloadPlaylist
export let overtime
export let overdue
Expand All @@ -35,6 +37,7 @@
!items.some((item) => item.type === "stopset") || (firstItem.type === "stopset" && firstItem.playing)
$: pauseDisabled = firstItem.type !== "stopset" || !firstItem.playing
$: isPaused = firstItem.type === "stopset" && !firstItem.playing
$: skipCurrentEnabled = firstItem.type === "stopset" && firstItem.startedPlaying
let ledState
$: if (playDisabled) {
Expand Down Expand Up @@ -103,23 +106,30 @@
{#if $userConfig.uiMode >= 2}
<div class="flex flex-col gap-2">
<div class="divider my-0 text-sm italic">Stop set control</div>
<div class="flex justify-center gap-2">
<div class="grid grid-cols-2 justify-center gap-2 gap-y-1 md:flex">
<div
class={firstItem.type === "stopset" && "tooltip tooltip-bottom tooltip-error"}
data-tip="Warning: this action will be logged!"
class={skipCurrentEnabled && "tooltip tooltip-bottom tooltip-error"}
data-tip="This action will be logged!"
>
<button
class="btn btn-error btn-sm pl-1.5"
disabled={firstItem.type !== "stopset"}
class="btn btn-error btn-sm w-full pl-1.5"
disabled={!skipCurrentEnabled}
on:click={skipCurrentStopset}
tabindex="-1"
>
<Icon icon={skipForwardOutlineIcon} class="h-6 w-6" /> Skip current
</button>
</div>
<button class="btn btn-warning btn-sm pl-1.5" on:click={regenerateNextStopset} tabindex="-1">
<Icon icon={reloadIcon} class="h-6 w-6" /> Regenerate next
</button>
<div class="tooltip tooltip-bottom tooltip-error" data-tip="This action will be logged!">
<button class="btn btn-warning btn-sm w-full pl-1.5" on:click={regenerateNextStopset} tabindex="-1">
<Icon icon={reloadIcon} class="h-6 w-6" /> Regenerate next
</button>
</div>
<div class="tooltip tooltip-bottom tooltip-error" data-tip="This action will be logged!">
<button class="btn btn-info btn-sm w-full pl-1.5" on:click={reloadPlaylist} tabindex="-1">
<Icon icon={reloadAlertIcon} class="h-6 w-6" /> Reload playlist
</button>
</div>
</div>
</div>
{/if}
Expand Down
1 change: 1 addition & 0 deletions client/src/stores/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ class GeneratedStopsetAssetBase {
get finished() {
return this.beforeActive
}

isAlternate() {
return this.alternateNumber > 0
}
Expand Down
9 changes: 8 additions & 1 deletion server/tomato/admin/rotator.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,14 @@


class RotatorAdmin(AiringEnabledMixin, NumAssetsMixin, TomatoModelAdminBase):
actions = ("enable", "disable", "enable_single_play", "disable_single_play", "enable_evenly_cycle", "disable_evenly_cycle")
actions = (
"enable",
"disable",
"enable_single_play",
"disable_single_play",
"enable_evenly_cycle",
"disable_evenly_cycle",
)
list_display = (
"name",
"enabled",
Expand Down

0 comments on commit d3b0322

Please sign in to comment.