在 Silverlight 4 中访问麦克风时防止网络摄像头灯亮起
我正在 Silverlight 4 中编写一个小型录音机组件。它工作正常,但我注意到当我录制音频时,网络摄像头上的灯会亮起,表明摄像头处于活动状态。
虽然我知道我没有对网络摄像头做任何阴险的事情,但我的用户完全有权利怀疑。是否可以告诉 Silverlight 我只对麦克风访问感兴趣而不激活网络摄像头?
FWIW 这是我访问麦克风的方式:
private CaptureSource _source = new CaptureSource();
private MemoryAudioSink _sink; // Inherits from AudioSink. Doesn't do much more
// than store PCM audio stream in memory
private void Record_Click(object sender, RoutedEventArgs e)
{
if (( CaptureDeviceConfiguration.AllowedDeviceAccess ||
CaptureDeviceConfiguration.RequestDeviceAccess() ) &&
_source.State == CaptureState.Stopped)
{
_sink = new MemoryAudioSink();
_sink.CaptureSource = _source;
_source.Start();
}
}
I'm writing a small audio recorder component in Silverlight 4. It works fine, but I've noticed that when I'm recording audio, the light on my webcam turns on indicating that the camera is active.
While I know that I'm not doing anything insidious with the webcam, my users would have every right to be suspicious. Is it possible to tell Silverlight that I'm only interested in microphone access and not activate the webcam?
FWIW here's how I'm accessing the mic:
private CaptureSource _source = new CaptureSource();
private MemoryAudioSink _sink; // Inherits from AudioSink. Doesn't do much more
// than store PCM audio stream in memory
private void Record_Click(object sender, RoutedEventArgs e)
{
if (( CaptureDeviceConfiguration.AllowedDeviceAccess ||
CaptureDeviceConfiguration.RequestDeviceAccess() ) &&
_source.State == CaptureState.Stopped)
{
_sink = new MemoryAudioSink();
_sink.CaptureSource = _source;
_source.Start();
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
即使您不告诉它,CaptureSource 也会频繁地获取默认视频输入设备。尽管您没有使用相机,但 Silverlight 确实正在访问它。希望微软能够在更高版本的 Silverlight 中修复这个奇怪的行为。
同时,只需将 VideoCaptureDevice 显式设置为 null:
CaptureSource will frequently grab the default video input device, even if you don't tell it to. Though you aren't using the camera, Silverlight is indeed accessing it. Hopefully, MS will fix this odd behavior in a later version of Silverlight.
In the meantime, just explicitly set VideoCaptureDevice to null:
这取决于网络摄像头驱动程序 - Silverlight 对此无法控制。
This would depend on the webcam driver - Silverlight would have no control over this.
我猜这与您使用
CaptureSource
有关。 Microsoft 的 网络网站声称:有没有一种方法可以在不创建自己的 CaptureSource 的情况下获取音频?
I'm guessing its related to your use of
CaptureSource
. Microsoft's web site claims that:Is there a way to get audio without creating your own CaptureSource?