fix status not working correctly

This commit is contained in:
Uriel committed 2024-10-28 18:29:36 +01:00
1 parent 986ef8d4b4
commit 583e335fc7
2 files changed
+16 -4

No files matched your search

+13 -2
View File
@@ -1,16 +1,20 @@
import { useRef, useState } from 'react';
import { PlayCircleIcon } from './icon/PlayIcon';
import { useDebouncedEffect } from '@/hooks/timeout';
import classNames from 'classnames';
export function PausableVideo({
src,
poster,
restartOnPause = false,
}: {
src?: string;
poster?: string;
restartOnPause?: boolean;
}) {
const videoRef = useRef<HTMLVideoElement | null>(null);
const [paused, setPaused] = useState(true);
const [atStart, setAtStart] = useState(true);
function toggleVideo() {
if (!videoRef.current) return;
@@ -18,7 +22,10 @@ export function PausableVideo({
videoRef.current.play();
} else {
videoRef.current.pause();
videoRef.current.currentTime = 0;
if (restartOnPause) {
videoRef.current.currentTime = 0;
}
setAtStart(videoRef.current.currentTime === 0);
}
setPaused(videoRef.current.paused);
}
@@ -34,7 +41,11 @@ export function PausableVideo({
return (
<button className="relative appearance-none h-fit" onClick={toggleVideo}>
<div
className="absolute w-[100px] h-[100px] top-0 bottom-0 left-0 right-0 m-auto fill-background-20"
className={classNames(
'absolute w-[100px] h-[100px] top-0 bottom-0 left-0 right-0 m-auto',
'fill-background-20',
paused && !atStart && 'opacity-50'
)}
hidden={!paused}
>
<PlayCircleIcon width={100}></PlayCircleIcon>
@@ -2,13 +2,14 @@ package dev.slimevr.status
import solarxr_protocol.rpc.StatusDataUnion
import solarxr_protocol.rpc.StatusMessageT
import java.util.concurrent.ConcurrentHashMap
import java.util.concurrent.CopyOnWriteArrayList
import java.util.concurrent.atomic.AtomicInteger
class StatusSystem {
private val listeners: MutableList<StatusListener> = CopyOnWriteArrayList()
private val statuses: MutableMap<Int, StatusDataUnion> = HashMap()
private val prioritizedStatuses: MutableSet<Int> = HashSet()
private val statuses: MutableMap<Int, StatusDataUnion> = ConcurrentHashMap()
private val prioritizedStatuses: MutableSet<Int> = ConcurrentHashMap.newKeySet()
private val idCounter = AtomicInteger(1)
fun addListener(listener: StatusListener) {