Skip to content

CreateFromMediaCaptureAsync Fails #8

@jlorek

Description

@jlorek

I'm trying to capture an image from a running camera preview.

    public async Task InitializeCamera()
    {
        var cameraID = await GetCameraID(Windows.Devices.Enumeration.Panel.Back);
        var settings = new MediaCaptureInitializationSettings
        {
            StreamingCaptureMode = StreamingCaptureMode.Video,
            VideoDeviceId = cameraID.Id,
        };

        _mediaCapture = new MediaCapture();
        await _mediaCapture.InitializeAsync(settings);
        _mediaCapture.SetPreviewRotation(VideoRotation.Clockwise90Degrees);

        Camera.Source = _mediaCapture;
        await _mediaCapture.StartPreviewAsync();

        MediaReader capture = await MediaReader.CreateFromMediaCaptureAsync(_mediaCapture);
        // ...
    }

But when calling CreateFromMediaCaptureAsync an exception is thrown:

An exception of type 'System.Exception' occurred in mscorlib.ni.dll but was not handled in user code
Additional information: The request is invalid in the current state. (Exception from HRESULT: 0xC00D36B2)

I don't get an exception when i uncomment the StartPreviewAsync line. But then i also get no preview...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions