的Windows Phone 8.1摄像头初始化 - 拒绝访问异常 [英] Windows Phone 8.1 Camera Initialisation - Access Denied Exception

查看:441
本文介绍了的Windows Phone 8.1摄像头初始化 - 拒绝访问异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用8.1 MediaCapture类为Windows Phone。

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.

踢球的是,它完美的作品在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显示出preVIEW。

_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摄像头初始化 - 拒绝访问异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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