Skip to main content
Version: 1.1.x

Change Audio Input Device - Flutter

During the meeting at any point a participant wishes to switch his/her input audio device, it can be done using the below mentioned methods.

info

This feature is only available on the Web and Desktop; if you want to use it on Mobile, please refer this guide.

getMics()

  • getMics() method will help you to list down all possible connected audio devices which will return a list of MediaDeviceInfo objects.

  • MediaDeviceInfo will contain the deviceId and label for the device.

changeMic()

  • You can switch the audio input device by using the changeMic() which will take the MediaDeviceInfo object as parameter to which you want to switch the audio input.

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 Input Device"),
onPressed: () => {
showDialog(
context: context,
builder: (context) => AlertDialog(
title: const Text("Select Audio Device"),
content: Column(
mainAxisAlignment: MainAxisAlignment.center,
mainAxisSize: MainAxisSize.min,
children: <Widget>[
SingleChildScrollView(
reverse: true,
child: Column(
children: _room
.getMics()
.map(
(device) => ElevatedButton(
child: Text(device.label),
onPressed: () => {
_room.changeMic(device),
Navigator.pop(context)
},
),
)
.toList(),
),
)
],
),
),
);
}),
]
);
}
}

API Reference

The API references for all the methods and events utilized in this guide are provided below.

Got a Question? Ask us on discord