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

[Q&A]ios微信浏览器中默认采用手机扬声器吗? #130

Open
JImumu opened this issue Jan 10, 2025 · 3 comments
Open

[Q&A]ios微信浏览器中默认采用手机扬声器吗? #130

JImumu opened this issue Jan 10, 2025 · 3 comments
Assignees
Labels
question Further information is requested

Comments

@JImumu
Copy link

JImumu commented Jan 10, 2025

Please describe the question.
我带上耳机进入房间自动播放语音时,默认使用扬声器播放,我要如何做才能默认使用耳机播放?

@JImumu JImumu added the question Further information is requested label Jan 10, 2025
@JImumu
Copy link
Author

JImumu commented Jan 10, 2025

不带耳机进入房间,然后再带上耳机是会自动切换到耳机的。

@Rychou
Copy link
Collaborator

Rychou commented Jan 10, 2025

这个 case 是已知 iOS 的 bug,已经向 apple 反馈该问题了:https://bugs.webkit.org/show_bug.cgi?id=285164

@JImumu
Copy link
Author

JImumu commented Jan 10, 2025

这个 case 是已知 iOS 的 bug,已经向 apple 反馈该问题了:https://bugs.webkit.org/show_bug.cgi?id=285164

似乎是ios音频输入和输出只能是同一个设备,可能是sdk中默认使用了手机麦克风作为输入导致的。我用下面方法貌似可以解决。

function isIOS() {
  const userAgent = navigator.userAgent || navigator.vendor || window.opera;
  return /iPad|iPhone|iPod/.test(userAgent) && !window.MSStream;
}

const startAudio = async () => {
  try {
    if (isIOS()) {
      const micList = await TRTC.getMicrophoneList();
      await trtc.startLocalAudio({
        option: {
          microphoneId: micList[micList.length - 1].deviceId,
        },
      });
    } else {
      await trtc.startLocalAudio();
    }
  } catch (e) {
    console.log('开启本地音频采集失败:', e);
  }
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants