setAudioDevice method
Sets the current AudioDevice for audio output.
- Currently selected AudioDevice can be accessed using
state.audioDevice
orstream.audioDevice
. - The list of currently available AudioDevices can be obtained accessed using
state.audioDevices
orstream.audioDevices
.
Implementation
@override
Future<void> setAudioDevice(AudioDevice audioDevice,
{bool synchronized = true}) {
Future<void> function() async {
if (disposed) {
throw AssertionError('[Player] has been disposed');
}
await waitForPlayerInitialization;
await waitForVideoControllerInitializationIfAttached;
final name = 'audio-device'.toNativeUtf8();
final value = audioDevice.name.toNativeUtf8();
mpv.mpv_set_property_string(
ctx,
name.cast(),
value.cast(),
);
calloc.free(name);
calloc.free(value);
}
if (synchronized) {
return lock.synchronized(function);
} else {
return function();
}
}