Skip to content

Handling device notifications

Adwyzz (OLED Edition) edited this page Feb 23, 2022 · 3 revisions

If you want to get notified whenever a new camera is connected or disconnected, you can use the CameraManager class.

var manager = new CameraManager();

Note: you can specify an alternative device input format if the default one doesn't fit your use-case.

By default, it is

  • DShow for Windows,
  • V4l2 for Linux (and the only one available),
  • AVFoundation for MacOS.
using SeeShark.FFmpeg;

var manager = new CameraManager(DeviceInputFormat.VfWCap);

From your instance of CameraManager that you created to instantiate cameras, you'll find two events: OnNewDevice and OnLostDevice.

In order to properly get notified though, you will need to perform a sync operation.

There are two ways to perform sync operations:

  • The automatic way, updating every second, only requires you to call StartWatching() once (and StopWatching() to stop updating).

  • The manual way, requires you to call the blocking method SyncDevices() every time.

Note: SyncDevices() is immediately called once upon creating a new CameraManager, so you don't need to call it again if you only want to get camera devices once.