androidx / media

Jetpack Media3 support libraries for media use cases, including ExoPlayer, an extensible media player for Android
https://developer.android.com/media/media3
Apache License 2.0
1.71k stars 411 forks source link

Problem with audio playback in Android Auto #1683

Closed patryk84a closed 2 months ago

patryk84a commented 2 months ago

I am not sure where the problem is. But I think it is a problem with my application which I built on the media3 library. I tried other applications such as Musicolet which uses an older version of the Media library, and everything is fine there. I also used Media Controller Tester to test my application. The application is correctly detected as an application with the Auto supported implementation. It passes all tests correctly, the media library is also correctly detected. Now let's move on to Android Auto. For testing I use Android Auto - Desktop Head Unit. Connection via USB. My application is correctly detected there, the media is also displayed. Unfortunately, during playback there is no sound from the computer speakers or from the phone speakers. The progress bar moves forward but without sound. Sometimes it happens that the sound is there for a moment and then disappears. When the sound disappears, the console displays the message: [I]: Audio stream close, buffered = 53248 , and when the sound is played, the message: [W]: Audio start: Audio stream already playing. Here I also tried the Musicolet application and the problem does not occur, the sound plays without interruptions. Is there something I need to additionally implement in my application so that the streaming does not close?

patryk84a commented 2 months ago

Ok. The problem was caused by the lack of focus settings in the player. After adding AudioAttributes everything is fine.