Videos
Devices can add support for streaming video, which can be viewed from the mobile app & dashboards.
Supported Video Types
Getting Started with Videos
Example β WebRTC
import Homey from 'homey';
export default class MyWebRTCDevice extends Homey.Device {
/*
* WebRTC works by creating an offer SDP in the frontend, exchanging it for
* an answer SDP through the cameras API, and using that answer SDP in the
* frontend to set up the connection.
*/
async onInit() {
try {
const video = await this.homey.videos.createVideoWebRTC();
/*
* This listener is called when the user opens the camera stream in the
* mobile app. The argument is an SDP offer generated by the mobile appp.
*/
video.registerOfferListener(async (offerSdp) => {
// Normally, you would call an API to exchange an SDP offer for an SDP answer
const result = await this.oAuth2Client.createStream(offerSdp);
return {
answerSdp: result.answerSdp,
};
});
/*
* Attach the camera to the device.
*/
await this.setCameraVideo('main', 'Main Camera', video);
} catch (err) {
this.error('Error creating camera:', err);
}
}
}Example β WebRTC without Data Channel
Example β RTSP
Example β RTMP
Example β HLS
Example β DASH
Apps SDK Reference
Last updated
Was this helpful?