switchMedia method
Implementation
Future<void> switchMedia(EnxController obj) async {
if(kIsWeb){
List list = await EnxRtc.getDevices();
Map<String, dynamic> device = convertMapToMap(list[0]);
List<dynamic> micList = device["micList"];
// deviceListWeb=micList.map((e) => e).toList();
deviceList.value = micList.map((device) => device["label"]).toList();
}else{
deviceList.value = await EnxRtc.getDevices();
}
mediaDeviceList.clear();
for (var i = 0; i < deviceList.length; i++) {
var mediaDevice=MediaDeviceModel.name(deviceList[i], false,i);
// if(selectedMedia==deviceList[i]){
//
// mediaDevice.status=true;
// }
mediaDeviceList.add(mediaDevice);
}
for (var mediaDevice in mediaDeviceList) {
print('Raj ${mediaDevice.name } +${selectedDevice.value} ');
if (mediaDevice.name == selectedMedia) {
mediaDevice.status=true;
selectedMediaDeviceModel.value=mediaDevice;
}
}
showSwitchAudioDialog(context,obj);
/* String deviceName = '';
print('dsvxc$selectedMedia');
if (selectedMedia.contains('EARPIECE') ||
selectedMedia.contains('Earpiece')) {
if (Platform.isIOS) {
deviceName = 'Speaker';
} else {
deviceName = 'SPEAKER_PHONE';
}
} else {
if (Platform.isIOS) {
deviceName = 'Earpiece';
} else {
deviceName = 'EARPIECE';
}
}
print('dsvxc1$deviceName');
await EnxRtc.switchMediaDevice(deviceName);*/
}