2015-05-21 3 views
0

Как вы можете использовать приложение камеры по умолчанию в окне предварительного просмотра Windows 10?Что используется с CameraCaptureUi в предварительном просмотре windows 10

+0

Microsoft добавила Windows.Media.Capture.CameraCaptureUI Тип в Windows 10 выпуска SDK 10158. Для получения дополнительной информации посмотрите на HTTP : //blogs.windows.com/buildingapps/2015/06/30/windows-10-sdk-preview-build-10158-released/ –

ответ

0

Для инициализации камеры

Debug.WriteLine("InitializeCameraAsync"); 

      if (_mediaCapture == null) 
      { 
       // Attempt to get the front camera if one is available, but use any camera device if not 
       var cameraDevice = await FindCameraDeviceByPanelAsync(Windows.Devices.Enumeration.Panel.Front); 

       if (cameraDevice == null) 
       { 
        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; 
       _mediaCapture.Failed += MediaCapture_Failed; 

       var settings = new MediaCaptureInitializationSettings { VideoDeviceId = cameraDevice.Id }; 

       // Initialize MediaCapture 
       try 
       { 
        await _mediaCapture.InitializeAsync(settings); 
        _isInitialized = true; 
       } 
       catch (UnauthorizedAccessException) 
       { 
        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 _mediaCapture.CapturePhotoToStreamAsync(ImageEncodingProperties.CreateJpeg(), stream); 
+0

Я могу использовать камеру приложения в своей заявке –

+0

Если вы можете, то это лучший вариант иначе вам придется столкнуться со многими авариями, так как конкретный пакет th вы хотите, чтобы поиск не присутствовал, иначе вы не сможете вернуться к своему приложению, как только откроется другое приложение. var options = new Windows.System.LauncherOptions(); options.PreferredApplicationPackageFamilyName = "YourAppPackage"; options.PreferredApplicationDisplayName = "YourAppName"; // Если у пользователя нет приложений, установленных для обработки URI var success = await Windows.System.Launcher.LaunchUriAsync (uri, options); – Jerin

+0

Для получения дополнительной информации о фрагменте кода, посмотрите: http://aka.ms/2015builduniversalcamerasample – Mike

Смежные вопросы