How to get FMOD to play sound over Android Auto?

So the problem im experiencing is this: java - Audio playback on Android Auto not working - Stack Overflow

0

I developed an Android app that plays audio, and I need that sound to be able to be played in Android Auto (AA).

At the moment, my app only plays the sound through the Android device.

Testing with the Desktop Head Unit (AA emulator) via USB, I get sounds from apps like YouTube, or MIUI apps (Gallery or Music) to be played on the AA.

These apps don’t have any kind of icon in the AA Launcher or some kind of Activity. And that’s precisely what I want, just playing the audio without having to create any GUI.

Some things I’ve tried to implement but without success.

build.gradle

dependencies {
    implementation 'androidx.car.app:app:1.2.0'
}

AndroidManifest.xml

<application>
    <meta-data
        android:name="com.google.android.gms.car.application"
        android:resource="@xml/automotive_app_desc"/>
</application>

res/xml/automotive_app_desc.xml

<automotiveApp>
    <uses name="media"/>
</automotiveApp>

MainActivity.java

// Request audio focus
audioManager.requestAudioFocus(audioFocusChangeListener, AudioManager.STREAM_MUSIC, AudioManager.AUDIOFOCUS_GAIN_TRANSIENT_MAY_DUCK);

// FMOD API plays an audio in a Thread
FMODService.play();

I’m using an FMOD API (C++ library) to play audio, but I don’t think there’s a problem with that.

How can I play audio through Android Auto?

Thanks.

Hi,

Unfortunately, FMOD is not in charge of selecting the output system. This will have to be done through the Android API. I will link to some documentation that may provide assistance: Audio y video  |  Desarrolladores de Android  |  Android Developers.