【问题标题】:Windows phone 8.1 Camera Initialisation - UnAuthorizedExceptionWindows phone 8.1 相机初始化 - UnAuthorizedException
【发布时间】:2014-10-07 02:32:10
【问题描述】:

我正在尝试在我的 windows phone 8.1 通用应用程序上使用 MediaCapture api 启动相机。该代码在 Windows 8.1 和 Windows Phone 8.1 模拟器上运行良好。我能够启动相机并拍照。

但它会在 Windows Phone 8.1 设备上引发 UnauthorizedException。类似的问题被问到Here

但是,我不知道是否有人解决了这个问题。我正在设备上侧载应用程序进行测试。我的要求是在加载的应用程序上启动相机。

代码sn-p:

初始化 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);

                }

拍照:

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

【问题讨论】:

  • 可能很难找到解决 UnauthorizedException 的方法。 IMO 这是上次更新后出现的错误-我的工作示例也引发异常(因此 MSDN 示例)。我们可能不得不等到下一次更新。
  • 因为我们在设备上运行 Windows Phone 8.1 操作系统预览版。它可能需要适当的固件更新来支持最新的 MediaCapture api。所以,我只是认为代码在操作系统的官方版本上可能会正常工作。同样,这只是我的预感。

标签: c# camera windows-phone-8.1


【解决方案1】:

这个错误似乎已在上次更新中得到纠正。

正如我在开发者预览版 8.10.14176.243 上测试的那样,MediaCapture.InitializeAsync 现在应该可以正常工作了。

【讨论】:

    猜你喜欢
    • 2014-10-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-06-17
    • 2023-04-03
    • 1970-01-01
    • 2014-04-10
    相关资源
    最近更新 更多