Note that the helper class maintains a reference to the app's CoreDispatcher and updates the collection of cameras within calls to RunAsync to ensure that the UI bound to the collection is updated on the UI thread.Īlso, this example handles the DeviceWatcher.Updated event in addition to the Added and Removed events. Typical apps would wrap the MediaFrameSourceGroup in a custom model class.
CONNECT A REMOTE CAMERA SWITCHER STUDIO UPDATE
The following example shows a helper class that uses a DeviceWatcher to create and update an ObservableCollection of MediaFrameSourceGroup objects to support data binding to the list of cameras. Pass this ID into the MediaFrameSourceGroup.FromIdAsync method to get a MediaFrameSourceGroup object that you can use to retrieve frames from the camera. Each of these objects has an Id property that is the identifier for the network camera for which the event was fired. The event args passed into the Added and Removed event handlers are a DeviceInformation or a DeviceInformationUpdate object, respectively. Until you stop the watcher by calling Stop, the Added event will be raised when new network camera devices become available and the Removed event will be raised when a camera device becomes unavailable. When you start the returned DeviceWatcher by calling the Start method, it will raise the Added event for every network camera that is currently available. To monitor only network cameras, you should use the AQS string shown above. The helper method MediaFrameSourceGroup.GetDeviceSelector returns an AQS string that will monitor locally-connected and remote network cameras.