Silverlight 4 Capture源未停止 [英] Silverlight 4 Capture source is not stopped

查看:46
本文介绍了Silverlight 4 Capture源未停止的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究Silverlight项目,以将音频记录在网页上.

I am working on a Silverlight project to record the audio on a web page.

单击暂停"按钮后,代码将始终引发异常:

After I clicked the Pause button the code will always throw an exception:

捕获源未停止

如果我在这行代码上放置一个断点并在那里等待3-5秒,然后运行代码,则不会抛出异常.

If I put a break point on this line of code and wait there for 3-5 seconds then run the code, no exception will be threw.

    if (audioSink.CaptureSource.State == CaptureState.Started) (break point is on this line)

这是代码

   private void Pause(object sender, RoutedEventArgs e)
    {
        //System.Threading.Thread.Sleep(TimeSpan.FromSeconds(5));
        if (audioSink.CaptureSource.State == CaptureState.Started)
        {
            audioSink.CaptureSource.Stop();

            this.btnPause.IsEnabled = false;
            this.btnRecord.IsEnabled = true;
            this.btnSave.IsEnabled = true;
        }
    }

   audioSink.CaptureSource.Stop(); (This is the line of code which throws the exception)

推荐答案

不确定是否有帮助:

在使用视频源时,我倾向于使用 CaptureDeviceConfiguration.AllowDeviceAccess 属性,以检查是否可以操纵捕获对象.

While using video source I tend to use CaptureDeviceConfiguration.AllowDeviceAccess property in order to check whether I can manipulate the capture object.

您可以通过调用

You can obtain the access to the device by calling CaptureDeviceConfiguration.RequestDeviceAccess. You should be calling this method before calling the Start method of the capture. If you do this on the Start method, than you should already have the access and call the Stop method without having problems.

这篇关于Silverlight 4 Capture源未停止的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆