import type {InputAudioTrack} from 'mediabunny'; import {useEffect, useState} from 'react'; import {renderHumanReadableAudioCodec} from '~/lib/render-codec-label'; import {PacketList} from './PacketList'; import {TextButtonWithChevron} from './TexrButtonWithChevron'; import {Table, TableBody, TableCell, TableRow} from './ui/table'; import {usePackets} from './use-packets'; export const AudioTrackOverview: React.FC<{ readonly track: InputAudioTrack; readonly showPackets: boolean; readonly setShowPackets: (showPackets: boolean) => void; }> = ({track, showPackets, setShowPackets}) => { const packets = usePackets({track}); const [sampleRate, setSampleRate] = useState(null); const [numberOfChannels, setNumberOfChannels] = useState(null); useEffect(() => { track.getSampleRate().then((sr) => setSampleRate(sr)); track.getNumberOfChannels().then((ch) => setNumberOfChannels(ch)); }, [track]); if (showPackets) { return ; } return ( Type Audio Packets setShowPackets(true)}> {packets.length} Codec {renderHumanReadableAudioCodec(track.codec)} WebCodecs Codec String {track.codec} Channels {numberOfChannels ?? '...'} Sample Rate {sampleRate ?? '...'}
); };