@nicoewok1604 said:
I am making my first Android game and I am running into a few issues.
First, one that I solved was that I can only use AudioStreamPlayers instead of AudioStreamPlayer2D nodes for an Android game.
If I recall correctly, AudioStreamPlayer2D nodes play the audio relative to the active Camera2D node so audio sources further away play quieter than those closer to the player/Camera2D. AudioStreamPlayer nodes just play the audio at the volume given regardless of any Camera2D nodes or anything.
I just wanted to mention it because the distance from the Camera2D is probably why it wasn't working, if I had to guess. I pretty much always just use AudioStreamPlayer nodes though as I found it can be a little difficult to get the settings just right for AudioStreamPlayer2D nodes.
The third problem I ran into is that I have an AudioStreamPlayer for background music (with both problem fixes from before) that is set on autoload so it starts with the game and doesn't stop with changing a scene. In the Editor, it works fine, but on the Android device (I also used a virtual one) it doesn't play. Even when I tell it to with code.
I would see if you can confirm that it is supposed to be playing on the node-level by printing the playing
boolean: print ($AudioStreamPlayer.playing)
. If it returns true
, then it should be playing and then it's something else outside of the node itself that is causing the issue.
Something that might be causing the issue is the file format of the audio file, as I know that at least for textures there can be some format incompatibilities on mobile platforms compared to desktop. If the printing returns that it is playing the music, I would see if using a .wav
file works, as I believe .wav
is fully supported on all platforms.