Silverlight 4 Capture源未停止

编程入门 行业动态 更新时间:2024-10-27 18:30:26
本文介绍了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.

您可以通过调用 CaptureDeviceConfiguration.RequestDeviceAccess .在调用捕获的Start方法之前,应该先调用此方法.如果在Start方法上执行此操作,则应该已经可以访问并调用Stop方法而不会出现问题.

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源未停止

本文发布于:2023-07-11 11:55:21,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1093963.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Silverlight   Capture

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!