C# Windows Media Capture-402587628错误“;找不到与此错误代码关联的文本。”;
尝试初始化Async mediaCapture时,第二个“catch”语句中出现问题C# Windows Media Capture-402587628错误“;找不到与此错误代码关联的文本。”;,c#,win-universal-app,windows-10,windows-10-universal,C#,Win Universal App,Windows 10,Windows 10 Universal,尝试初始化Async mediaCapture时,第二个“catch”语句中出现问题 如果没有提供任何错误详细信息,我如何检查出了什么问题?这段代码对我来说运行正常。你是否在应用程序清单中设置了麦克风和网络摄像头功能?是的,我设置了。在Windows Phone 10上使用摄像头是否有任何问题?在PC机上它工作得很好…这个代码对我来说很好。你是否在应用程序清单中设置了麦克风和网络摄像头功能?是的,我设置了。在Windows Phone 10上使用摄像头是否有任何问题?在PC上,它工作得很好。。。
如果没有提供任何错误详细信息,我如何检查出了什么问题?这段代码对我来说运行正常。你是否在应用程序清单中设置了麦克风和网络摄像头功能?是的,我设置了。在Windows Phone 10上使用摄像头是否有任何问题?在PC机上它工作得很好…这个代码对我来说很好。你是否在应用程序清单中设置了麦克风和网络摄像头功能?是的,我设置了。在Windows Phone 10上使用摄像头是否有任何问题?在PC上,它工作得很好。。。
private async Task InitializeCameraAsync()
{
if (_mediaCapture == null)
{
// Get available devices for capturing pictures
var allVideoDevices = await DeviceInformation.FindAllAsync(DeviceClass.VideoCapture);
// Get the desired camera by panel
DeviceInformation cameraDevice =
allVideoDevices.FirstOrDefault(x => x.EnclosureLocation != null &&
x.EnclosureLocation.Panel == Windows.Devices.Enumeration.Panel.Front);
// If there is no camera on the specified panel, get any camera
cameraDevice = cameraDevice ?? allVideoDevices.FirstOrDefault();
if (cameraDevice == null)
{
//ShowMessageToUser("No camera device found.");
Debug.WriteLine("No camera device found.");
return;
}
// Create MediaCapture and its settings
_mediaCapture = new MediaCapture();
// Register for a notification when video recording has reached the maximum time and when something goes wrong
//_mediaCapture.RecordLimitationExceeded += MediaCapture_RecordLimitationExceeded;
var mediaInitSettings = new MediaCaptureInitializationSettings { VideoDeviceId = cameraDevice.Id };
// Initialize MediaCapture
try
{
await _mediaCapture.InitializeAsync(mediaInitSettings);
_isInitialized = true;
}
catch (UnauthorizedAccessException)
{
//ShowMessageToUser("The app was denied access to the camera");
Debug.WriteLine("The app was denied access to the camera");
}
catch (Exception ex)
{
Debug.WriteLine("Exception when initializing MediaCapture with {0}: {1}", cameraDevice.Id, ex.ToString());
}
// If initialization succeeded, start the preview
if (_isInitialized)
{
// Figure out where the camera is located
if (cameraDevice.EnclosureLocation == null || cameraDevice.EnclosureLocation.Panel == Windows.Devices.Enumeration.Panel.Unknown)
{
// No information on the location of the camera, assume it's an external camera, not integrated on the device
_externalCamera = true;
}
else
{
// Camera is fixed on the device
_externalCamera = false;
// Only mirror the preview if the camera is on the front panel
//_mirroringPreview = (cameraDevice.EnclosureLocation.Panel == Windows.Devices.Enumeration.Panel.Front);
}
//await StartPreviewAsync();
//UpdateCaptureControls();
}
}
}