-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow delays and durations to be set on groups
Signed-off-by: Axel Boberg <[email protected]>
- Loading branch information
1 parent
35794fc
commit 8218520
Showing
5 changed files
with
102 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
plugins/rundown/app/components/RundownItemProgress/index.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import React from 'react' | ||
|
||
import './style.css' | ||
|
||
export function RundownItemProgress ({ item }) { | ||
const [progress, setProgress] = React.useState(0) | ||
|
||
React.useEffect(() => { | ||
if (item?.state !== 'playing' && item?.state !== 'scheduled') { | ||
setProgress(0) | ||
return | ||
} | ||
|
||
let shouldLoop = true | ||
|
||
function loop () { | ||
if (!shouldLoop) { | ||
return | ||
} | ||
|
||
let progress = 0 | ||
|
||
switch (item?.state) { | ||
case 'playing': | ||
progress = (Date.now() - item?.didStartPlayingAt) / item?.data?.duration | ||
break | ||
case 'scheduled': | ||
progress = (item?.willStartPlayingAt - Date.now()) / (item?.willStartPlayingAt - item?.wasScheduledAt) | ||
break | ||
} | ||
|
||
if (Number.isNaN(progress) || (progress >= 1 && item?.state === 'playing')) { | ||
setProgress(0) | ||
return | ||
} | ||
|
||
setProgress(Math.max(Math.min(progress, 1), 0)) | ||
|
||
window.requestAnimationFrame(loop) | ||
} | ||
loop() | ||
|
||
return () => { shouldLoop = false } | ||
}, [item?.state, item?.didStartPlayingAt, item?.willStartPlayingAt]) | ||
|
||
return ( | ||
<div className='RundownItemProgress'> | ||
{ | ||
['playing', 'scheduled'].includes(item?.state) && | ||
<div className='RundownItemProgress-progress' style={{ transform: `scale(${progress}, 1)`, backgroundColor: item?.data?.color }} /> | ||
} | ||
</div> | ||
) | ||
} |
29 changes: 29 additions & 0 deletions
29
plugins/rundown/app/components/RundownItemProgress/style.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2024 Sveriges Television AB | ||
* | ||
* SPDX-License-Identifier: MIT | ||
*/ | ||
|
||
.RundownItemProgress { | ||
position: absolute; | ||
width: 100%; | ||
height: 100%; | ||
|
||
left: 0; | ||
top: 0; | ||
} | ||
|
||
.RundownItemProgress-progress { | ||
position: absolute; | ||
width: 100%; | ||
height: 100%; | ||
|
||
bottom: 0; | ||
right: 0; | ||
left: 0; | ||
|
||
transform-origin: left; | ||
|
||
opacity: 0.3; | ||
z-index: -1; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters