Skip to content

Commit

Permalink
Pick stopsets and assets eligibility based on their approximate start…
Browse files Browse the repository at this point in the history
… time in the playlist
  • Loading branch information
dtcooper committed Aug 12, 2023
1 parent 9c49e0a commit 1dcd2bf
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ Head over to <http://localhost:8888/> in your web browser.
- [x] Idiot mode, easy mode, advanced mode
- [ ] ~~Timeout on fetch?~~ (websockets makes this unneeded, except for downloading files)
- [x] Attempt to prevent duplicate assets from playing within a certain time period
- [ ] Start/end time for assets in client are based on "is likely to play at" time
- [x] Start/end time for assets in client are based on "is likely to play at" time
- [x] Empty rotators are warned on (based on feature flag)
- [x] Deal with non-playable assets (error state ones)
- [x] Compression and selecting output device using a bridge to
Expand Down
16 changes: 14 additions & 2 deletions client/src/main/Player.svelte
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<script>
import dayjs from "dayjs"
import { tick } from "svelte"
import PlayBar from "./player/Bar.svelte"
import PlayButtons from "./player/Buttons.svelte"
Expand Down Expand Up @@ -35,11 +36,20 @@
document.getElementById("playlist").scroll({ top: 0, behavior: "smooth" })
}
window.durationOfItems = () => {
return items.reduce((s, item) => s + item.remaining, 0)
}
const addStopset = () => {
// If previous item is not a wait interval
let shouldPrependWait = $config.WAIT_INTERVAL > 0 && items.length > 0 && items[items.length - 1].type !== "wait"
let generatedStopset = $db.generateStopset(null, processItem, updateUI)
const secondsUntilPlay = items.reduce(
(s, item) => s + item.remaining,
shouldPrependWait ? $config.WAIT_INTERVAL : 0
)
const likelyPlayTime = dayjs().add(secondsUntilPlay, "seconds")
let generatedStopset = $db.generateStopset(likelyPlayTime, processItem, updateUI)
if (generatedStopset) {
if (shouldPrependWait) {
Expand Down Expand Up @@ -68,7 +78,9 @@
addStopset()
} else {
// swap it out, maintaining generatedId so UI doesn't trigger a transition
let generatedStopset = $db.generateStopset(null, processItem, updateUI, items[nextStopset].generatedId)
const secondsUntilPlay = items.slice(0, nextStopset).reduce((s, item) => s + item.remaining, 0)
const likelyPlayTime = dayjs().add(secondsUntilPlay, "seconds")
let generatedStopset = $db.generateStopset(likelyPlayTime, processItem, updateUI, items[nextStopset].generatedId)
if (generatedStopset) {
items[nextStopset].done(true) // Mark swap out one as done
items[nextStopset] = generatedStopset
Expand Down

0 comments on commit 1dcd2bf

Please sign in to comment.