File tree Expand file tree Collapse file tree
bundle/hooks/useDeviceList Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11{
22 "name" : " @siberiacancode/reactuse" ,
3- "version" : " 1.0.5 " ,
3+ "version" : " 1.0.6 " ,
44 "description" : " The ultimate collection of react hooks" ,
55 "author" : {
66 "name" : " SIBERIA CAN CODE 🧊" ,
Original file line number Diff line number Diff line change @@ -47,11 +47,13 @@ export const useDeviceList = (...params) => {
4747 const hasCamera = list . some ( ( device ) => device . kind === 'videoinput' ) ;
4848 const hasMicrophone = list . some ( ( device ) => device . kind === 'audioinput' ) ;
4949 if ( ! hasCamera && ! hasMicrophone ) return update ( ) ;
50- const stream = await navigator . mediaDevices . getUserMedia ( {
51- video : hasCamera ,
52- audio : hasMicrophone
53- } ) ;
54- stream ?. getTracks ( ) . forEach ( ( track ) => track . stop ( ) ) ;
50+ try {
51+ const stream = await navigator . mediaDevices . getUserMedia ( {
52+ video : hasCamera ,
53+ audio : hasMicrophone
54+ } ) ;
55+ stream . getTracks ( ) . forEach ( ( track ) => track . stop ( ) ) ;
56+ } catch { }
5557 setDevices ( list ) ;
5658 optionsRef . current ?. onUpdate ?. ( list ) ;
5759 return list ;
Original file line number Diff line number Diff line change @@ -95,12 +95,13 @@ export const useDeviceList = ((...params: any[]) => {
9595 const hasMicrophone = list . some ( ( device ) => device . kind === 'audioinput' ) ;
9696 if ( ! hasCamera && ! hasMicrophone ) return update ( ) ;
9797
98- const stream = await navigator . mediaDevices . getUserMedia ( {
99- video : hasCamera ,
100- audio : hasMicrophone
101- } ) ;
102-
103- stream ?. getTracks ( ) . forEach ( ( track ) => track . stop ( ) ) ;
98+ try {
99+ const stream = await navigator . mediaDevices . getUserMedia ( {
100+ video : hasCamera ,
101+ audio : hasMicrophone
102+ } ) ;
103+ stream . getTracks ( ) . forEach ( ( track ) => track . stop ( ) ) ;
104+ } catch { }
104105
105106 setDevices ( list ) ;
106107 optionsRef . current ?. onUpdate ?.( list ) ;
Load diff Large diffs are not rendered by default.
Original file line number Diff line number Diff line change @@ -135,12 +135,12 @@ const Demo = () => {
135135 < div ref = { dropdownRef } className = 'relative' >
136136 < button
137137 aria-label = 'Select camera'
138- className = 'flex items-center gap-2'
138+ className = 'flex w-44 items-center gap-2'
139139 data-variant = 'secondary'
140140 type = 'button'
141141 onClick = { ( ) => dropdownMenu . toggle ( ) }
142142 >
143- < span className = 'max -w-[120px] truncate text-xs' >
143+ < span className = 'min -w-0 flex-1 truncate text-left text-xs' >
144144 { activeCamera ?. label || 'Default camera' }
145145 </ span >
146146 < ChevronDownIcon className = 'size-4' />
You can’t perform that action at this time.
0 commit comments