Example 2/@videodb/robopeek-react @videodb/robopeek-mcap
Compose your player
Build your own player from the library's parts and your own components. Inside one McapPlayer:
- Library parts:
Player.Stage,Frames,Instruction,Transport,Scrubber,Tracks, andTopicsfrom/mcap - Your parts: the header, the Play button, the speed chips, the live signal bars, and the tiles that replace one-value charts
- Shared state: every part reads the same playback through
usePlayer(). Positions are seconds, andrateis a speed multiplier
3 MB · 3 cameras · H.264 video
Use your own URL or file
Files are read locally. Remote URLs must allow CORS and are fetched as supplied.
import type { Source } from '@videodb/robopeek-mcap'
import { Player } from '@videodb/robopeek-react'
import { McapPlayer, Topics, useRecording } from '@videodb/robopeek-react/mcap'
import { BigPlay, CurrentSignal, RecordingHeader, ScalarTile, SpeedChips } from './MyRecordingParts.tsx'
import '../../compose/compose.css'
// Library parts (Player.*, Topics) and your own components (from MyRecordingParts.tsx) side by side in one
// McapPlayer. Everything inside it shares one playback state.
export function ComposedRecording({ source }: { source: Source }) {
const { recording, status } = useRecording(source)
if (!recording || recording.origin === undefined) return <p className="mm-wait">{status.phase === 'error' ? status.error : 'Opening the recording…'}</p>
return (
<McapPlayer recording={recording} loading={status.phase === 'loading'} className="mm-player">
<RecordingHeader />
<div className="mm-main">
<Player.Stage>
<Player.Instruction />
<Player.Frames />
<Player.Transport>
<Player.StepBack />
<BigPlay />
<Player.StepForward />
<Player.Scrubber />
<Player.Counter />
</Player.Transport>
<SpeedChips />
</Player.Stage>
<div className="mm-side">
<CurrentSignal />
<Topics title="Topics in this file" />
</div>
</div>
{/* Built-in charts; one-value tracks swapped for your own tile. */}
<Player.Tracks renderItem={(key, track, fallback) => (track.dim === 1 ? <ScalarTile name={key} track={track} /> : fallback)} />
</McapPlayer>
)
}The Code tab contains the source files used by this example.
