Mediacaptureextensions

Potpourri of methods managing MediaCapture


Project maintained by mmaitre314 Hosted on GitHub Pages — Theme by mattgraham

Build status NuGet package

To enable the helper methods below add this NuGet package to your C# project and using MediaCaptureExtensions; to .cs files.

Select back or front camera

var settings = new MediaCaptureInitializationSettings();
await settings.SelectVideoDeviceAsync(VideoDeviceSelection.BackOrFirst);

var capture = new MediaCapture();
await capture.InitializeAsync(settings);

Rotate preview without extra black bars

var capture = new MediaCapture();
await capture.InitializeAsync();

await capture.SetPreviewRotationAsync(VideoRotation.Clockwise90Degrees);

Direct access to bytes in IBuffer

This extension requires "unsafe" code to be enabled.

var buffer = new Buffer(100);
byte* data = buffer.GetData();
for (int i = 0; i < buffer.Capacity; i++)
{
    data[i] = 42;
}
buffer.Length = buffer.Capacity;