Change Video Input Device - Flutter
During the meeting at any point a participant wishes to switch his/her input video device, it can be done using the below mentioned methods.
getCameras()
This method of the
Room
object will give you the list of all the available cameras which can be shown in a list.This method will return an array of
MediaDeviceInfo
which will contain thedeviceId
andlabel
of the camera input device.
changeCam()
- Once you know which device you want to switch camera input to, you can pass the
deviceId
to this method to change the camera input device.
Example
import 'package:flutter/material.dart';
import 'package:videosdk/videosdk.dart';
class MeetingScreen extends StatefulWidget {
...
}
class _MeetingScreenState extends State<MeetingScreen> {
late Room _room;
@override
void initState() {
...
}
@override
Widget build(BuildContext context) {
return Column(
children:[
ElevatedButton(
child: Text("Change Camera"),
onPressed: () => {
showDialog(
context: context,
builder: (context) => AlertDialog(
title: const Text("Select Camera Device"),
content: Column(
mainAxisAlignment: MainAxisAlignment.center,
mainAxisSize: MainAxisSize.min,
children: <Widget>[
SingleChildScrollView(
reverse: true,
child: Column(
children: _room
.getCameras()
.map(
(device) => ElevatedButton(
child: Text(device.label),
onPressed: () => {
_room.changeCam(device.id),
Navigator.pop(context)
},
),
)
.toList(),
),
)
],
),
),
);
}),
]
);
}
}
API Reference
The API references for all the methods and events utilised in this guide are provided below.
Got a Question? Ask us on discord