@@ -12,8 +12,8 @@ import {
1212import { MicrophoneIcon } from '@phosphor-icons/react/dist/ssr' ;
1313import { useSession } from '@/components/app/session-provider' ;
1414import { AgentControlBar } from '@/components/livekit/agent-control-bar/agent-control-bar' ;
15+ import { TrackControl } from '@/components/livekit/agent-control-bar/track-control' ;
1516import { TrackDeviceSelect } from '@/components/livekit/agent-control-bar/track-device-select' ;
16- import { TrackSelector } from '@/components/livekit/agent-control-bar/track-selector' ;
1717import { TrackToggle } from '@/components/livekit/agent-control-bar/track-toggle' ;
1818import { Alert , AlertDescription , AlertTitle , alertVariants } from '@/components/livekit/alert' ;
1919import { AlertToast } from '@/components/livekit/alert-toast' ;
@@ -285,15 +285,17 @@ export const COMPONENTS = {
285285 </ div >
286286
287287 < div className = "relative flex flex-col justify-center gap-4" >
288- < AudioBarVisualizer
289- size = { size as audioBarVisualizerVariantsSizeType }
290- state = { state }
291- audioTrack = { micTrackRef ! }
292- barCount = { parseInt ( barCount ) || undefined }
293- className = "mx-auto"
294- />
295- < div className = "border-border space-y-4 rounded-xl border p-4" >
296- < div className = "text-center" > Original BarVisualizer</ div >
288+ < div className = "grid h-40 place-items-center" >
289+ < AudioBarVisualizer
290+ size = { size as audioBarVisualizerVariantsSizeType }
291+ state = { state }
292+ audioTrack = { micTrackRef ! }
293+ barCount = { parseInt ( barCount ) || undefined }
294+ className = "mx-auto"
295+ />
296+ </ div >
297+ < div className = "text-center" > Original BarVisualizer</ div >
298+ < div className = "border-border grid h-40 place-items-center space-y-4 rounded-xl border p-4" >
297299 < BarVisualizer
298300 size = { size as audioBarVisualizerVariantsSizeType }
299301 state = { state }
@@ -330,52 +332,76 @@ export const COMPONENTS = {
330332 } ,
331333
332334 // Track device select
333- TrackDeviceSelect : ( ) => (
334- < Container componentName = "TrackDeviceSelect" >
335- < div className = "grid grid-cols-2 gap-4" >
336- < div >
337- < StoryTitle > Size default</ StoryTitle >
338- < TrackDeviceSelect kind = "audioinput" />
339- </ div >
340- < div >
341- < StoryTitle > Size sm</ StoryTitle >
342- < TrackDeviceSelect size = "sm" kind = "audioinput" />
343- </ div >
344- </ div >
345- </ Container >
346- ) ,
335+ // TrackDeviceSelect: () => (
336+ // <Container componentName="TrackDeviceSelect">
337+ // <div className="grid grid-cols-2 gap-4">
338+ // <div>
339+ // <StoryTitle>Size default</StoryTitle>
340+ // <TrackDeviceSelect kind="audioinput" />
341+ // </div>
342+ // <div>
343+ // <StoryTitle>Size sm</StoryTitle>
344+ // <TrackDeviceSelect size="sm" kind="audioinput" />
345+ // </div>
346+ // </div>
347+ // </Container>
348+ // ),
347349
348350 // Track toggle
349- TrackToggle : ( ) => (
350- < Container componentName = "TrackToggle" >
351- < div className = "grid grid-cols-2 gap-4" >
352- < div >
353- < StoryTitle > Track.Source.Microphone</ StoryTitle >
354- < TrackToggle variant = "outline" source = { Track . Source . Microphone } />
355- </ div >
356- < div >
357- < StoryTitle > Track.Source.Camera</ StoryTitle >
358- < TrackToggle variant = "outline" source = { Track . Source . Camera } />
359- </ div >
360- </ div >
361- </ Container >
362- ) ,
351+ // TrackToggle: () => (
352+ // <Container componentName="TrackToggle">
353+ // <div className="grid grid-cols-2 gap-4">
354+ // <div>
355+ // <StoryTitle>Track.Source.Microphone</StoryTitle>
356+ // <TrackToggle variant="outline" source={Track.Source.Microphone} />
357+ // </div>
358+ // <div>
359+ // <StoryTitle>Track.Source.Camera</StoryTitle>
360+ // <TrackToggle variant="outline" source={Track.Source.Camera} />
361+ // </div>
362+ // </div>
363+ // </Container>
364+ // ),
363365
364- // Track selector
365- TrackSelector : ( ) => (
366- < Container componentName = "TrackSelector" >
367- < div className = "grid grid-cols-2 gap-4" >
368- < div >
369- < StoryTitle > Track.Source.Camera</ StoryTitle >
370- < TrackSelector kind = "videoinput" source = { Track . Source . Camera } />
371- </ div >
372- < div >
373- < StoryTitle > Track.Source.Microphone</ StoryTitle >
374- < TrackSelector kind = "audioinput" source = { Track . Source . Microphone } />
366+ // Track control
367+ TrackControl : ( ) => {
368+ const { microphoneTrack, localParticipant } = useLocalParticipant ( ) ;
369+ const micTrackRef = useMemo < TrackReferenceOrPlaceholder | undefined > ( ( ) => {
370+ return {
371+ participant : localParticipant ,
372+ source : Track . Source . Microphone ,
373+ publication : microphoneTrack ,
374+ } as TrackReference ;
375+ } , [ localParticipant , microphoneTrack ] ) ;
376+
377+ useMicrophone ( ) ;
378+
379+ return (
380+ < Container componentName = "TrackSelector" >
381+ < div className = "grid grid-cols-2 gap-8" >
382+ < div className = "flex flex-col gap-8" >
383+ < div >
384+ < StoryTitle > Track.Source.Microphone</ StoryTitle >
385+ < TrackControl kind = "audioinput" source = { Track . Source . Microphone } />
386+ </ div >
387+ < div >
388+ < StoryTitle > Track.Source.Microphone</ StoryTitle >
389+ < TrackControl
390+ kind = "audioinput"
391+ source = { Track . Source . Microphone }
392+ audioTrackRef = { micTrackRef }
393+ />
394+ </ div >
395+ </ div >
396+
397+ < div >
398+ < StoryTitle > Track.Source.Camera</ StoryTitle >
399+ < TrackControl kind = "videoinput" source = { Track . Source . Camera } />
400+ </ div >
375401 </ div >
376- </ div >
377- </ Container >
378- ) ,
402+ </ Container >
403+ ) ;
404+ } ,
379405
380406 // Chat entry
381407 ChatEntry : ( ) => (
0 commit comments