Windows Phone 8.1 相机初始化

编程入门 行业动态 更新时间:2024-10-26 08:32:09
本文介绍了Windows Phone 8.1 相机初始化 - 访问被拒绝异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

使用适用于 Windows Phone 的 8.1 MediaCapture 类.

Using the 8.1 MediaCapture classes for Windows Phone.

已声明音频"和网络摄像头"的功能,其中 90% 是导致异常的原因.

Have declared the capabilities for "Audio" and "Webcam", which 90% is what would be the cause of the exception.

Kicker 是,它在 WP 模拟器中完美运行,但在实际设备上中断.

Kicker is, it works perfectly in the WP emulator, but breaks on an actual device.

确切的例外是这里:

我添加了大量检查,以确保我们没有重新初始化已经初始化的相机或尝试在初始化之前读取..等等(因为我认为问题是由以下原因引起的)所以这不太可能就是这样.

I have added a mountain of checks to make sure we aren't re-initializing the already initialized camera or trying to read before the initializations.. etc (as I assumed the issue was being caused by) So it is very unlikely to be that.

private async Task InitializeCameraAsync() { if (_isInitialized) { Debug.WriteLine("Skipping unnecessary initialization"); return; } Debug.WriteLine("Initializing camera media capture..."); _deviceCapture = new MediaCapture(); await _deviceCapture.InitializeAsync(new MediaCaptureInitializationSettings { VideoDeviceId = _cameraInfoCollection[_currentVideoDevice].Id, PhotoCaptureSource = PhotoCaptureSource.VideoPreview, AudioDeviceId = _microphoneInfoCollection[_currentAudioDevice].Id StreamingCaptureMode = StreamingCaptureMode.Video }); Debug.WriteLine("Initialized camera media capture!"); // For code completion only, unlikely to be relevant // Set up low-lag photo capture if (IsNotUsingInstantCapture) { Debug.WriteLine("Preparing low-lag photo capture"); var imageEncoding = ImageEncodingProperties.CreateJpeg(); imageEncoding.Width = PhotoCaptureWidth; imageEncoding.Height = PhotoCaptureHeight; _lowLagPhotoCapture = await _deviceCapture.PrepareLowLagPhotoCaptureAsync(imageEncoding); } _isInitialized = true; Debug.WriteLine("Initialized camera!"); }

_mediacapture 随后被绑定到 xaml CaptureElement 的 .source 以显示预览.

_mediacapture is then being bound to the .source of a xaml CaptureElement to show a preview.

推荐答案

这是 Windows api 的临时错误.它已在 2014 年 9 月 24 日发布的 Windows Phone 8.1 更新中得到修复.

It was a temporary bug with the Windows api. It was fixed with the Windows Phone 8.1 update that was released the 24th of september 2014.

更多推荐

Windows Phone 8.1 相机初始化

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

发布评论

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

>www.elefans.com

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