Windows phone 8.1 Camera Initialisation - UnAuthorizedException

与世无争的帅哥 提交于 2020-01-23 00:37:05

问题


I am trying to launch camera using MediaCapture api on my windows phone 8.1 universal app. The code works fine on Windows 8.1 and Windows Phone 8.1 emulator. I am able to launch camera and take picture.

But it throws an UnauthorizedException on Windows Phone 8.1 device. Similar question is asked Here

But, i dont know whether someone got around this problem. And I am sideloading application on device for testing. My requirement is to launch camera on sideloaded applications.

Code snippet:

Initializing MediaCapture:

                DeviceInformation cameraDevice = await GetCameraID();
                if (cameraDevice != null)
                {
                    mMediaManager_ = new Windows.Media.Capture.MediaCapture();
                    var settings = new Windows.Media.Capture.MediaCaptureInitializationSettings();
                    settings.StreamingCaptureMode = Windows.Media.Capture.StreamingCaptureMode.Video;
                    settings.MediaCategory = Windows.Media.Capture.MediaCategory.Other;
                    settings.AudioProcessing = Windows.Media.AudioProcessing.Default;
                    settings.VideoDeviceId = cameraDevice.Id;                       

                    await mMediaManager_.InitializeAsync(settings);
                    mMediaManager_.RecordLimitationExceeded += new Windows.Media.Capture.RecordLimitationExceededEventHandler(RecordLimitationExceeded);
                    mMediaManager_.Failed += new Windows.Media.Capture.MediaCaptureFailedEventHandler(RecordFailed);

                }

Taking Photo:

                mMediaStorageFile_ = await folder.CreateFileAsync(fileName, CreationCollisionOption.GenerateUniqueName);
                ImageEncodingProperties imageProperties = ImageEncodingProperties.CreateJpeg();
                await mMediaManager_.CapturePhotoToStorageFileAsync(imageProperties, mMediaStorageFile_);                   
                mCameraScreen_.setPreviewImage(mMediaStorageFile_);

回答1:


It seems that this bug has been corrected with the last update.

As I've tested on developer preview version 8.10.14176.243, MediaCapture.InitializeAsync should work now without problems.



来源:https://stackoverflow.com/questions/25291122/windows-phone-8-1-camera-initialisation-unauthorizedexception

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