Add the capability to set the default route to Speakers or Earpiece (not only toggle)
Add the capability to set the route to Speakers or Earpiece (before start playing) I did not find this feature in the current implementation and/or examples.
Full Description Using the component as an audio guide inside a museum, for example, it is essential for the user to select the type of earpiece or speaker routing and to be able to maintain this selection throughout his visit.
With the current implementation it is not possible to set the signal routing before playing.
Example Code
Current method for changing signal routing:
await _audioPlayer.earpieceOrSpeakersToggle();
Desired method for selecting the signal routing before start playing the audio file:
for Speakers (or headphones)
await _audioPlayer.setPlayingRoute(PlayingRoute.EARPIECE);
await _audioPlayer.setPlayingRoute(PlayingRoute.SPEAKERS);
Platforms iOS, Android, Web
looking for same thing
Would be nice if this was automatic, at the moment it players though the device speaks making the plugin useless.
I would like to know as well, as this was present in 0.19.1 as:
await audioPlayer.earpieceOrSpeakersToggle();
Cannot find any docs regarding removal/refactoring or whether it now somehow lives in AudioContext.
Came across a few issues where people reported it did not work, is that why it was removed? Thank you.
We did not remove it, we just made it more granular for each platform:
final audioContext = AudioContext(
iOS: AudioContextIOS(
options: [
AVAudioSessionOptions.mixWithOthers,
],
),
android: AudioContextAndroid(
audioMode: AndroidAudioMode.inCommunication,
isSpeakerphoneOn: false,
usageType: AndroidUsageType.voiceCommunication,
),
);
audioPlayer.setAudioContext(audioContext);
You can play around with the values, also in our example app.