Have you explored the newest version of the OpenTok platform? Check out OpenTok 2.0, built on top of WebRTC. Learn more

DeviceEvent class

A DevicePanel object dispatches a devicesSelected event when the user selects a camera or microphone in the device panel.

A Publisher object dispatches a deviceInactive event when the camera or microphone used by the publisher is inactive. If a camera or microphone attached to a publisher is initially inactive, the Publisher immediately dispatches a deviceInactive event. Also, when a camera or microphone is disconnected, the Publisher object dispatches the deviceInactive event.

A Publisher object dispatches a invalidDeviceName event if you specify an invalid name for the microphoneName or cameraName property of the properties parameter of the Session.publish() method or the TB.initPublisher() method.

For a code example that uses the DeviceEvent object, see DeviceManager Example.

DeviceEvent properties

The DeviceEvent object has the following properties:

camera (Camera) — For the devicesSelected event, this is the currently selected camera. For the deviceInactive event, it is either the camera that became inactive (or null if a microphone became inactive). For the invalidDeviceName event, it is the invalid camera (if the camera name is invalid); the camera.name name property is set to the invalid name passed into the Session.publish() method, and the camera.status name property is set to "invalid".

microphone (Microphone) — For the devicesSelected event, this is the currently selected microphone. For the deviceInactive event, it is either the microphone that became inactive or null (if a camera became inactive). For the invalidDeviceName event, it is the invalid microphone (or null if the camera name is invalid); the microphone.name name property is set to the invalid name passed into the Session.publish() method or the TB.initPublisher() method, and the microphone.status name property is set to "invalid".

target (Object) — The object that dispatched the event.

type (String) — The type of event. There are two types of DeviceEvent events: devicesSelected and deviceInactive.

IRC Live Chat

Have a quick question? Chat with TokBox Support on IRC. Join chat