Windows Phone 8.1 相机初始化 - 访问被拒绝异常

Windows Phone 8.1 Camera Initialisation - Access Denied Exception(Windows Phone 8.1 相机初始化 - 访问被拒绝异常)
本文介绍了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 相机初始化 - 访问被拒绝异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

How to MOQ an Indexed property(如何最小起订量索引属性)
Mocking generic methods in Moq without specifying T(在 Moq 中模拟泛型方法而不指定 T)
How Moles Isolation framework is implemented?(Moles Isolation 框架是如何实现的?)
Difference between Dependency Injection and Mocking Framework (Ninject vs RhinoMocks or Moq)(依赖注入和模拟框架之间的区别(Ninject vs RhinoMocks 或 Moq))
How to mock Controller.User using moq(如何使用 moq 模拟 Controller.User)
How do I mock a class without an interface?(如何模拟没有接口的类?)