Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
File size: 1,635 Bytes
c1f12bf 3c75c2c c1f12bf cdd4011 3c75c2c c1f12bf cdd4011 c1f12bf 2068834 c1f12bf 2068834 c1f12bf cdd4011 c1f12bf 7fd5ad1 2068834 cdd4011 c1f12bf 7fd5ad1 2068834 a477577 7fd5ad1 c1f12bf |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
import { useEffect } from 'react'
import { ClapTimeline, useTimeline, SegmentResolver } from '@aitube/timeline'
import { cn } from '@/lib/utils'
import { useMonitor } from '@/services/monitor/useMonitor'
import { useResolver } from '@/services/resolver/useResolver'
import { useUI } from '@/services/ui'
export function Timeline() {
const isReady = useTimeline((s) => s.isReady)
const resolveSegment: SegmentResolver = useResolver((s) => s.resolveSegment)
const setSegmentResolver = useTimeline((s) => s.setSegmentResolver)
const jumpAt = useMonitor((s) => s.jumpAt)
const checkIfPlaying = useMonitor((s) => s.checkIfPlaying)
const togglePlayback = useMonitor((s) => s.togglePlayback)
const setJumpAt = useTimeline((s) => s.setJumpAt)
const setIsPlaying = useTimeline((s) => s.setIsPlaying)
const setTogglePlayback = useTimeline((s) => s.setTogglePlayback)
const startLoop = useResolver((s) => s.startLoop)
// this is important: we connect the monitor to the timeline
useEffect(() => {
if (!isReady) {
return
}
setSegmentResolver(resolveSegment)
setJumpAt(jumpAt)
setIsPlaying(checkIfPlaying)
setTogglePlayback(togglePlayback)
// not sure if that's the best place, but once the timeline is loaded
// we need to apply theme to it
useUI.getState().applyThemeToComponents()
startLoop()
}, [
isReady,
setSegmentResolver,
setJumpAt,
setIsPlaying,
setTogglePlayback,
startLoop,
checkIfPlaying,
jumpAt,
resolveSegment,
togglePlayback,
])
return <ClapTimeline showFPS={false} className={cn('bg-[rgb(58,54,50)]')} />
}
|