or9ob
or9ob

Reputation: 2392

Flutter/just_audio: How can I identify the deviceType that is being used to play audio in?

I am using just_audio with audio_service and just_audio_background to play audio in my app (in-app as well as background audio).

Is it possible for me to identify the type of device that is being used to play the audio? Such as, is the audio being played via the device (iOS/Android phone/tablet) itself, or perhaps via Bluetooth, CarPlay, AndroidAuto etc.


I could not find anything relevant in SO, in just_audio docs and issues. And ChatGPT is hallucinating (it's telling me some methods that don't exist, but if they did - would have been exactly what I wanted) :)

Upvotes: 0

Views: 660

Answers (2)

Volodymyr Buberenko
Volodymyr Buberenko

Reputation: 668

There are a few packages that should allow you to achieve what you want:

Upvotes: 1

Becca
Becca

Reputation: 314

You can use the Platform class that comes with Flutter.

 if(Platform.isAndroid){
   //Write Android code here
 }else if(Platform.isIOS){
  //Write ios code here
 }

Check out the Platform class you have access to other device types as well. I hope this solves your issues :)

Upvotes: -1

Related Questions