-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(web): obtain media device label #10
Conversation
Fix the issue where Firefox browser device list cannot be read, replace 'label' with 'kind+DeviceId'. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Use English comment. please
- Remove unless line
- Remove unless and debug
console.log
- Code style
About code style:
http://www.ruanyifeng.com/blog/2012/04/javascript_programming_style.html
https://www.cnblogs.com/Yellow-ice/p/15127392.html
webapp/components/device.tsx
Outdated
@@ -11,8 +11,47 @@ import SvgAudio from './svg/audio' | |||
import SvgVideo from './svg/video' | |||
import { SvgPresentCancel, SvgPresentToAll } from './svg/present' | |||
|
|||
export default function DeviceBar(props: { streamId: string }) { | |||
const [permissionAudio, setPermissionAudio] = useState("") | |||
// 1.将每个设备的 deviceId 和 label 转换为可显示的格式。如果 label 为空,会使用设备类型和 deviceId 作为显示名称。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use English comment. please
webapp/components/device.tsx
Outdated
return { value, text }; | ||
} | ||
|
||
// 2.uniqByValue 去重 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
English comment
webapp/components/device.tsx
Outdated
@@ -48,7 +87,7 @@ export default function DeviceBar(props: { streamId: string }) { | |||
// NOTE: | |||
// Chrome: audio_capture, video_capture | |||
// Safari: microphone, camera | |||
if (status.name === "audio_capture" || "microphone") { | |||
if (status.name === "audio_capture" || "microphone") { // "microphone"作为string不一直为ture吗? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(status.name === "audio_capture" || status.name === "microphone")
webapp/components/device.tsx
Outdated
// 使用 deviceInfoToOption加载设备列表 | ||
const audios = devices.filter(i => i.kind === 'audioinput').map(deviceInfoToOption) | ||
|
||
console.log('this is audios:',audios) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this line
webapp/components/device.tsx
Outdated
|
||
const videos = devices.filter(i => i.kind === 'videoinput').map(deviceInfoToOption); | ||
//const audios: Device[] = devices.filter(i => i.kind === 'audioinput') | ||
//const videos: Device[] = devices.filter(i => i.kind === 'videoinput') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove
webapp/components/device.tsx
Outdated
|
||
// 使用 uniqByValue 去重 | ||
const uniqueAudios = uniqByValue(audios); | ||
console.log('this is uniqueAudios:',uniqueAudios) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this line
webapp/components/device.tsx
Outdated
} catch (error) { | ||
console.error('Failed to set video device:', error) | ||
} | ||
}else{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} else {
webapp/components/device.tsx
Outdated
@@ -113,7 +189,7 @@ export default function DeviceBar(props: { streamId: string }) { | |||
setLoadingScreen(true) | |||
await onChangedDeviceVideo(userStatus.screen ? deviceNone.deviceId : deviceScreen.deviceId) | |||
setLoadingScreen(false) | |||
} | |||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trim tail
webapp/components/device.tsx
Outdated
console.error('Failed to set audio device:', error) | ||
} | ||
} | ||
//await setCurrentDeviceAudio(device.value) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove unless line
webapp/components/device.tsx
Outdated
if (device) { | ||
try { | ||
await setCurrentDeviceVideo(device.value) | ||
console.log('Video device set successfully') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
try {
await setCurrentDeviceVideo(device.value)
BTW: CLA. please. https://github.com/binbat/woom/blob/main/.github/CLA.md#list-of-contributors You can read this example: binbat/live777#95 |
Signed-off-by: winter_NaN <[email protected]>
I do have configured the PGP key and signed it. However, the email address in my Git configuration is not the one for GPG signing (bound to GitHub). I just changed it with |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
webapp/components/device.tsx
Outdated
export default function DeviceBar(props: { streamId: string }) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This blank line is unused
webapp/components/device.tsx
Outdated
if (device) await setCurrentDeviceAudio(device.deviceId) | ||
let device = uniqueAudios[0] | ||
if (device) | ||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (device) {
webapp/components/device.tsx
Outdated
{ | ||
try { | ||
await setCurrentDeviceAudio(device.value) | ||
console.log('Audio device set successfully') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this log
webapp/components/device.tsx
Outdated
if (device) { | ||
try { | ||
await setCurrentDeviceVideo(device.value) | ||
console.log('Video device set successfully') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this successfully log
webapp/components/device.tsx
Outdated
console.log('no video devices:') | ||
await setCurrentDeviceVideo(deviceNone.deviceId) | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This block indent style error
webapp/components/device.tsx
Outdated
setDeviceAudio([...audios]) | ||
setDeviceVideo([...videos, deviceScreen]) | ||
setDeviceAudio(convertToDevice(uniqueAudios,'audioinput')) | ||
setDeviceVideo(convertToDevice(uniqueVideos,'videoinput')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
convertToDevice(uniqueVideos, 'videoinput')
,
after add a
Correct the coding format and update issue solution. |
Fix the issue where Firefox browser device list cannot be read.