Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

No sound on Android
Started by MrNoob Oct 24 2019 08:05 AM

- - - - -
2 replies to this topic

Best Answer MrNoob , 25 October 2019 - 02:01 AM

Examaple:

function scene:show(event)
    if (phase == "will") then
    elseif (phase == "did") then
    audio.play(musicTrack, {channel=1, loops=-1})
    end
end

I have reserved "channel 1" in main.lua. In simmulation works perfect like any other sound.

From main.lua:

audio.reserveChannels(1)
audio.setVolume(0.5)
audio.setVolume(1, {channel=1})

I don't understand why it works in Simulation, if i build to Windows it also works but only on my PC ( ??? )

 

I already moved all my Audio files to different folder and OFC i changed directions in my CODE. Once again works perfect in Simulation but not after i Build it and send to another device, and YES, all files are inside of Project folder, im not using files from outside of this folder... 

 

I will try to convert wav to Ogg and check if it change something.

 

 

 

EDIT:

 

 

I changed one audio to ".ogg" and it works on Android  :ph34r:

 

 

Thanks 

nosoyhackercodigo

 

I think i know where is the problem, maybe i should convert to 16bit .wav file instead of 32bit wav.

 

Idk, i think i will just convert everything to .ogg and thats it.

[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

MrNoob

[GLOBAL: userInfoPane.html]
MrNoob
  • Observer

  • 2 posts
  • Corona SDK

Hi

 

I have problem with sound on android.

 

-In Simulator everything works,

-If i build Windows version of my game it works as well

-If i build Android then i have no sound

 

some of code:

-- All audio Variables on top of "game.lua"
local boomSoundSmall
local boomSoundMedium
local boomSoundBig
local pistolSound
local rifleSound
local rocketSound
local rocketSoundSilent
local plinkSound
local alarmSound
local winSound
local lostSound

function scene:create(event)
    boomSoundSmall = audio.loadSound("Data/Audio/BoomSmall.wav")
    boomSoundMedium = audio.loadSound("Data/Audio/BoomMedium.wav")
    boomSoundBig = audio.loadSound("Data/Audio/BoomBig.wav")
    pistolSound = audio.loadSound("Data/Audio/PistolShoot.wav")
    rifleSound = audio.loadSound("Data/Audio/RifleShoot.wav")
    rocketSoundSilent = audio.loadSound("Data/Audio/Rocket.wav")
    rocketSound = audio.loadSound("Data/Audio/RocketLOUD.wav")
    plinkSound = audio.loadSound("Data/Audio/Plink.wav")
    alarmSound = audio.loadSound("Data/Audio/Alarm.wav")
    winSound = audio.loadSound("Data/Audio/WinSound.wav")
    lostSound = audio.loadSound("Data/Audio/LostSound.wav")
    musicTrack = audio.loadStream("Data/Audio/StatekBackgroundSong.wav")
    battleTrack = audio.loadStream("Data/Audio/BossFight2.wav")
end

To play audio i'm using:

 audio.play(boomSoundSmall) audio.play(musicTrack, {channel=1, loops=-1})

ALSO i used ".wav" files in my older, small game and it WORKS FINE on same Android device (OnePlus 3t A3003 with Android 9 + OxygenOS 9.0.5)

 

Code from previous small game:

local RickSound
local ShovelSound

audio.play(ShovelSound)

function scene:create(event)
    RickSound = audio.loadSound("sfx/RickSound.wav")
    ShovelSound = audio.loadSound("sfx/ShovelSound.wav")
end

-So my first prediction was, maybe i should just create one folder "sfx" instead of going deep but i compared it to game made by Corona sdk developer called "Knight" and he is also putting every in different folders and there is no issue.

- Or maybe i should rename my Audio folder to sfx?

- Or use .ogg or .mp3 instead of .wav?

 

No idea, please help :)



[TOPIC: post.html]
#2

nosoyhackercodigo

[GLOBAL: userInfoPane.html]
nosoyhackercodigo
  • Enthusiast

  • 70 posts
  • Corona SDK

Have you tried converting to ogg?

 

Maybe your audio file use different codec or something?

If you convert the wav file to ogg and still doesn't work, maybe those wav files could be the problem.

 

Also you need to provide us with more code to help you. Maybe the part where you play those sounds.



[TOPIC: post.html]
#3

MrNoob

[GLOBAL: userInfoPane.html]
MrNoob
  • Observer

  • 2 posts
  • Corona SDK

  Best Answer

Examaple:

function scene:show(event)
    if (phase == "will") then
    elseif (phase == "did") then
    audio.play(musicTrack, {channel=1, loops=-1})
    end
end

I have reserved "channel 1" in main.lua. In simmulation works perfect like any other sound.

From main.lua:

audio.reserveChannels(1)
audio.setVolume(0.5)
audio.setVolume(1, {channel=1})

I don't understand why it works in Simulation, if i build to Windows it also works but only on my PC ( ??? )

 

I already moved all my Audio files to different folder and OFC i changed directions in my CODE. Once again works perfect in Simulation but not after i Build it and send to another device, and YES, all files are inside of Project folder, im not using files from outside of this folder... 

 

I will try to convert wav to Ogg and check if it change something.

 

 

 

EDIT:

 

 

I changed one audio to ".ogg" and it works on Android  :ph34r:

 

 

Thanks 

nosoyhackercodigo

 

I think i know where is the problem, maybe i should convert to 16bit .wav file instead of 32bit wav.

 

Idk, i think i will just convert everything to .ogg and thats it.




[topic_controls]
[/topic_controls]