Skip to content
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

Merged
merged 10 commits into from
Nov 5, 2024

Conversation

WinterJack002
Copy link
Contributor

Fix the issue where Firefox browser device list cannot be read.

@WinterJack002
Copy link
Contributor Author

Fix the issue where Firefox browser device list cannot be read, replace 'label' with 'kind+DeviceId'.

Copy link
Member

@a-wing a-wing left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Use English comment. please
  2. Remove unless line
  3. Remove unless and debug console.log
  4. 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

@@ -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 作为显示名称。
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use English comment. please

return { value, text };
}

// 2.uniqByValue 去重
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

English comment

@@ -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吗?
Copy link
Member

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")

// 使用 deviceInfoToOption加载设备列表
const audios = devices.filter(i => i.kind === 'audioinput').map(deviceInfoToOption)

console.log('this is audios:',audios)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this line


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')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove


// 使用 uniqByValue 去重
const uniqueAudios = uniqByValue(audios);
console.log('this is uniqueAudios:',uniqueAudios)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this line

} catch (error) {
console.error('Failed to set video device:', error)
}
}else{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

} else {

@@ -113,7 +189,7 @@ export default function DeviceBar(props: { streamId: string }) {
setLoadingScreen(true)
await onChangedDeviceVideo(userStatus.screen ? deviceNone.deviceId : deviceScreen.deviceId)
setLoadingScreen(false)
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trim tail

console.error('Failed to set audio device:', error)
}
}
//await setCurrentDeviceAudio(device.value)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove unless line

if (device) {
try {
await setCurrentDeviceVideo(device.value)
console.log('Video device set successfully')
Copy link
Member

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)

@a-wing
Copy link
Member

a-wing commented Oct 22, 2024

@WinterJack002
Copy link
Contributor Author

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 git config --global user.email. The next time I submit, it should show that it is verified.

Copy link
Member

@a-wing a-wing left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But, this patch has some problem is no resolve

This is use this patch is firefox:

Screenshot 2024-10-26 at 08 33 14

But this is live777 debugger show device in firefox

Screenshot 2024-10-26 at 08 32 49

export default function DeviceBar(props: { streamId: string }) {

Copy link
Member

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

if (device) await setCurrentDeviceAudio(device.deviceId)
let device = uniqueAudios[0]
if (device)
{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (device) {

{
try {
await setCurrentDeviceAudio(device.value)
console.log('Audio device set successfully')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this log

if (device) {
try {
await setCurrentDeviceVideo(device.value)
console.log('Video device set successfully')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this successfully log

console.log('no video devices:')
await setCurrentDeviceVideo(deviceNone.deviceId)

}
Copy link
Member

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

setDeviceAudio([...audios])
setDeviceVideo([...videos, deviceScreen])
setDeviceAudio(convertToDevice(uniqueAudios,'audioinput'))
setDeviceVideo(convertToDevice(uniqueVideos,'videoinput'))
Copy link
Member

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

@a-wing a-wing added the bug Something isn't working label Oct 26, 2024
@WinterJack002
Copy link
Contributor Author

Correct the coding format and update issue solution.

@a-wing a-wing merged commit 40a68b7 into binbat:main Nov 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants