Silverlight 4 Capture source is not stopped

*爱你&永不变心* 提交于 2019-12-12 05:38:33

问题


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:

Capture source is not stopped

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)

Here is the code

   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)

回答1:


Not sure if it might help:

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.



来源:https://stackoverflow.com/questions/12345689/silverlight-4-capture-source-is-not-stopped

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!