-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
221 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import type React from 'react' | ||
import { useEffect, useState } from 'react' | ||
import { useSettingsStore } from '../store/useSettingsStore' | ||
|
||
const AudioInputDevice: React.FC = () => { | ||
const [devices, setDevices] = useState<MediaDeviceInfo[]>([]) | ||
const setAudioInputDeviceId = useSettingsStore((state) => state.setAudioInputDeviceId) | ||
const audioInputDeviceId = useSettingsStore((state) => state.settings.audio.inputDeviceId) | ||
|
||
useEffect(() => { | ||
const getDevices = async () => { | ||
const permissionStatus = await navigator.permissions.query({ | ||
name: 'microphone' as PermissionName, | ||
}) | ||
|
||
const handlePermissionChange = async () => { | ||
if (permissionStatus.state === 'granted') { | ||
const devices = await navigator.mediaDevices.enumerateDevices() | ||
const audioInputDevices = devices.filter((device) => device.kind === 'audioinput') | ||
setDevices(audioInputDevices) | ||
} else { | ||
setDevices([]) | ||
} | ||
} | ||
|
||
// 初期状態の処理 | ||
handlePermissionChange() | ||
|
||
// 権限変更の監視 | ||
permissionStatus.onchange = handlePermissionChange | ||
|
||
return () => { | ||
// ククリーンアップ | ||
permissionStatus.onchange = null | ||
} | ||
} | ||
getDevices() | ||
}, []) | ||
|
||
const handleChange = (e: React.ChangeEvent<HTMLSelectElement>) => { | ||
setAudioInputDeviceId(e.target.value) | ||
} | ||
|
||
return ( | ||
<select onChange={handleChange} value={audioInputDeviceId}> | ||
{devices.map((device) => ( | ||
<option key={device.deviceId} value={device.deviceId}> | ||
{device.label || `Microphone ${device.deviceId}`} | ||
</option> | ||
))} | ||
</select> | ||
) | ||
} | ||
|
||
export default AudioInputDevice |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import type React from 'react' | ||
import { useEffect, useState } from 'react' | ||
import { useSettingsStore } from '../store/useSettingsStore' | ||
|
||
const AudioOutputDevice: React.FC = () => { | ||
const [devices, setDevices] = useState<MediaDeviceInfo[]>([]) | ||
const setAudioOutputDeviceId = useSettingsStore((state) => state.setAudioOutputDeviceId) | ||
const audioOutputDeviceId = useSettingsStore((state) => state.settings.audio.outputDeviceId) | ||
|
||
useEffect(() => { | ||
const getDevices = async () => { | ||
const permissionStatus = await navigator.permissions.query({ | ||
name: 'microphone' as PermissionName, | ||
}) | ||
|
||
const handlePermissionChange = async () => { | ||
if (permissionStatus.state === 'granted') { | ||
const devices = await navigator.mediaDevices.enumerateDevices() | ||
const audioOutputDevices = devices.filter((device) => device.kind === 'audiooutput') | ||
setDevices(audioOutputDevices) | ||
} else { | ||
setDevices([]) | ||
} | ||
} | ||
|
||
// 初期状態の処理 | ||
handlePermissionChange() | ||
|
||
// 権限変更の監視 | ||
permissionStatus.onchange = handlePermissionChange | ||
|
||
return () => { | ||
// ククリーンアップ | ||
permissionStatus.onchange = null | ||
} | ||
} | ||
getDevices() | ||
}, []) | ||
|
||
const handleChange = (e: React.ChangeEvent<HTMLSelectElement>) => { | ||
setAudioOutputDeviceId(e.target.value) | ||
} | ||
|
||
return ( | ||
<select onChange={handleChange} value={audioOutputDeviceId}> | ||
{devices.map((device) => ( | ||
<option key={device.deviceId} value={device.deviceId}> | ||
{device.label || `Speaker ${device.deviceId}`} | ||
</option> | ||
))} | ||
</select> | ||
) | ||
} | ||
|
||
export default AudioOutputDevice |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import type React from 'react' | ||
import { useEffect, useState } from 'react' | ||
import { useSettingsStore } from '../store/useSettingsStore' | ||
|
||
const VideoInputDevice: React.FC = () => { | ||
const [devices, setDevices] = useState<MediaDeviceInfo[]>([]) | ||
const setVideoInputDeviceId = useSettingsStore((state) => state.setVideoInputDeviceId) | ||
const videoInputDeviceId = useSettingsStore((state) => state.settings.video.inputDeviceId) | ||
|
||
useEffect(() => { | ||
const getDevices = async () => { | ||
const permissionStatus = await navigator.permissions.query({ | ||
name: 'camera' as PermissionName, | ||
}) | ||
|
||
const handlePermissionChange = async () => { | ||
if (permissionStatus.state === 'granted') { | ||
const devices = await navigator.mediaDevices.enumerateDevices() | ||
const videoInputDevices = devices.filter((device) => device.kind === 'videoinput') | ||
setDevices(videoInputDevices) | ||
} else { | ||
setDevices([]) | ||
} | ||
} | ||
|
||
// 初期状態の処理 | ||
handlePermissionChange() | ||
|
||
// 権限変更の監視 | ||
permissionStatus.onchange = handlePermissionChange | ||
|
||
return () => { | ||
// ククリーンアップ | ||
permissionStatus.onchange = null | ||
} | ||
} | ||
getDevices() | ||
}, []) | ||
|
||
const handleChange = (e: React.ChangeEvent<HTMLSelectElement>) => { | ||
setVideoInputDeviceId(e.target.value) | ||
} | ||
|
||
return ( | ||
<select onChange={handleChange} value={videoInputDeviceId}> | ||
{devices.map((device) => ( | ||
<option key={device.deviceId} value={device.deviceId}> | ||
{device.label || `Camera ${device.deviceId}`} | ||
</option> | ||
))} | ||
</select> | ||
) | ||
} | ||
|
||
export default VideoInputDevice |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters