NatDevice API

Cross Platform Media Device API for Unity Engine

Media Devices Made Easy

NatDevice is a cross-platform media device API. NatDevice simplifies your camera and microphone workflows.

First, find an available device:

// Find a rear-facing camera
var criterion = MediaDeviceQuery.Criteria.RearFacing;
var query = new MediaDeviceQuery(criterion);
var device = query.currentDevice as CameraDevice;
// Find a microphone
var criterion = MediaDeviceQuery.Criteria.AudioDevice;
var query = new MediaDeviceQuery(criterion);
var device = query.currentDevice as AudioDevice;

Then start streaming media data from the device:

// Start streaming the camera preview
var previewTexture = await device.StartRunning();
// The device will stream the preview to the `Texture2D` above
// Start streaming audio sample buffers
// The device will stream audio to the delegate below
void OnSampleBuffer (float[] sampleBuffer, long timestamp) => DoStuff();

From here, you can utilize tons of functionality provided by media devices to build your interactive applications.

Extensive and Lightweight

NatDevice is a lightweight API that provides extensive functionality for using media devices. Features include:

  • Stream the camera preview and microphone audio with very little latency.

  • Support for high resolution camera previews, at full HD and higher where supported.

  • Support for specifying microphone sample rate and channel count.

  • Extensive camera control including hi-res photo capture, flash, focus, exposure, white balance, torch, zoom, and orientation support.

  • Support for microphones with echo cancellation for karaoke and voice call apps.

  • ‚ÄčIntegration with OpenCV, for using computer vision algorithms with the camera.

  • VR support, compatible with GearVR and Google Cardboard.

Make sure to explore the full documentation to get a complete understanding of what the API offers.

Get NatDevice