在 Silverlight 4 中访问麦克风时防止网络摄像头灯亮起

发布于 2024-09-12 05:14:47 字数 805 浏览 8 评论 0原文

我正在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

上课铃就是安魂曲 2024-09-19 05:14:47

即使您不告诉它,CaptureSource 也会频繁地获取默认视频输入设备。尽管您没有使用相机,但 Silverlight 确实正在访问它。希望微软能够在更高版本的 Silverlight 中修复这个奇怪的行为。

同时,只需将 VideoCaptureDevice 显式设置为 null:

var _audioCaptureSource = new CaptureSource {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:

var _audioCaptureSource = new CaptureSource {VideoCaptureDevice = null};
离不开的别离 2024-09-19 05:14:47

这取决于网络摄像头驱动程序 - Silverlight 对此无法控制。

This would depend on the webcam driver - Silverlight would have no control over this.

罗罗贝儿 2024-09-19 05:14:47

我猜这与您使用 CaptureSource 有关。 Microsoft 的 网络网站声称

Silverlight 4 API 仅使用
视频场景中的 CaptureSource
音频可能不相关的地方。

有没有一种方法可以在不创建自己的 CaptureSource 的情况下获取音频?

I'm guessing its related to your use of CaptureSource. Microsoft's web site claims that:

Silverlight 4 APIs only use
CaptureSource in a video scenario
where audio may not be relevant.

Is there a way to get audio without creating your own CaptureSource?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文