麦克风检测 Actionscript 3
我在检测是否检测到麦克风时遇到一些问题。我正在运行函数 Microphone.getMicrophone()
,如果没有连接麦克风,或者用户在安全面板上单击了“拒绝”,则该函数应该返回 null ,对吧?
我面临的问题是,在某些没有安装麦克风的计算机上,Microphone.getMicrophone()
仍然跟踪为 [object Microphone]
。
例如,假设用户没有麦克风,并且在安全面板中单击允许,我无法验证是否切换到不同的控件。
如果有人可以阐明如何检测是否未连接麦克风,那么我会洗耳恭听。
预先非常感谢, 将要
I'm having a few problems detecting whether a microphone is detected or not. I'm running the function Microphone.getMicrophone()
and that should return null if there is no microphone attached, or if the user has clicked Deny on the security panel, right?
The problem I'm facing is, on some computers where there is no microphone installed, Microphone.getMicrophone()
still traces out as [object Microphone]
.
So say for example the user doesn't have a microphone, and clicks allow in the security panel, I can't validate whether to switch to different controls.
If anybody can shed some light on how to detect if there is no microphone connected, then I'm all ears.
Many thanks in advance,
Will
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
好吧,我建议在连接时进行麦克风测试,记录用户的 1-2 秒并将其发送回服务器进行评估,将其发送回用户并制作一些按钮供用户在听到声音时批准。这就是 Skype 所做的,您可以添加一些奇特的控制器,以在同一测试屏幕上具有适当的噪声阈值水平和输入/输出音量等。
我不确定,但即使 getMicrophone() 返回错误/不存在的设备,它也无法正确记录它。
Well, i would recommend to make mic test upon connection, record 1-2 seconds from user and send it back to server for evaluation, send it back to user and make some button for user to approve if he heard the sound. This is what Skype do, you can add some fancy controllers to have proper noise threshold level and in/out volume and such on the same test screen.
I'm not sure but even if getMicrophone() returns false/non existent device it cannot record it properly anyway.
您可以检查 mic.activityLevel 属性来检查是否有任何麦克风级别
,如果计算机有多个麦克风,您可以在 flash.media.Microphone.names 中迭代 amic 来检查每个级别。
you can check the mic.activityLevel property to check if there is any mic level
also, if the computer has multiple mics, you can iterate amic in flash.media.Microphone.names to check each level.
我建议检查
flash.media.Microphone.names
并查看它是否为空。I would advise to check
flash.media.Microphone.names
and see if it is empty.测试麦克风的示例代码
sample code to test a microphone