Sound delay on emulator in corona sdk
I'm currently creating a game with corona sdk. While creating game i faced issues in playing audio files. Issue was that, a tennis ball is dropped on ground and audio should be played. But what happen was the audio was delayed a second. On emulator the audio was synchronized but while i ported apk on my galaxy s2, android version 4.2.2 i faced a delay. Below is the code which i used to play audio. I loaded audio file first as program executed: local audio = audio.loadSound("hit ball.mp3") Then somewhere in middle I used collision and on collision I played that audio file: local function onCollisionSound() audio.play(audio) end ball:addEventListener("collision", onCollisionSound) I also tried with media api but it also didnt worked.
This may be an issue with OpenAL. All audio.* methods are based on OpenAL which is not natively supported by the Android NDK (which supports OpenSL ES instead). The solution to make it work is still a bit buggy and may introduced a delay with some Android versions/devices : (Directly from the Corona SDK documentation of audio.play()) NOTE: A known issue with Android causes sound to be delayed by 1 to 2 seconds when started. You may try to use the deprecated media.* API instead which doesn't use OpenAL, this may resolve your problem.
Generally with Android 4.1 and later, the audio.* API calls shouldn't be lagging. Google fixed the bug in the 4.1 release, but on older versions, it could still be a problem. However, that doesn't mean the device maker hasn't done some things that hurt sound performance. When exact timing is required, we do recommend using media.* API calls. Also, please make sure your sound clip doesn't have any delays at the beginning.
selectively upgrade existing sqlite database in corona by comparing database versions
Corona Near Field Comunication (NFR)
How can i make random generated quotes
Using perspective library with Corona SDK
What is the right way to zoom the camera out from a scene view?
Corona SDK Runtime Error on version 3.0.0
corona loadRemoteImage loading in another scene
What is a simple splash screen code for corona?
How to resize pickerwheel on corona sdk
How to allow external music/audio to continue in Corona SDK apps when they launch?
Can I put apps made on Corona SDK for windows on IOS?
Define coordinates with rotation (corona sdk)
Open 3rd party application in corona sdk
Corona SDK variable throughout different scenes
How to show Pop-ups in Corona SDK?
IDE for Corona SDK for Mac