getCurrentAudioOutput method

  1. @override
Future<AudioOutputDevice?> getCurrentAudioOutput()
override

Gets the currently active audio output device, or null if none/unknown.

Implementation

@override
Future<AudioOutputDevice?> getCurrentAudioOutput() async {
  final outputs = await getAvailableAudioOutputs();
  return outputs.firstWhere(
    (d) => d.isSelected,
    orElse: () => outputs.isNotEmpty
        ? outputs.first
        : const AudioOutputDevice(
            id: 'default',
            name: 'Default Audio Output',
            type: AudioOutputType.speaker,
            isSelected: true,
          ),
  );
}