Corona sound_decode triggered an error - audio

I'm receiving this message in loop at my console after I start my game:
sound_decode triggered an error
The code that is triggering this is:
local storyboard = require( "storyboard" )
local scene = storyboard.newScene()
local introsound = audio.loadStream("sounds/intro.mp3")
-- Called when the scene's view does not exist:
function scene:createScene( event )
local group = self.view
local background = display.newRect(0, 0, display.contentWidth, display.contentHeight)
background.strokeWidth = 3
background:setFillColor(170, 150, 170)
background:setStrokeColor(0, 0, 0)
local desliga = function (event)
if event.completed then
audio.stop()
audio.dispose(introsound)
introsound = nil
print ("disposing")
end
end
audio.play(introsound,{onComplete=desliga})
-- audio.play(introsound)
Am I doing something wrong? or is it missing something?

You probably should not be loading the sound in the main chunk, and you probably shouldn't be playing it in the createScene() function. I would consider doing all of them in enterScene() since you probably don't want your sound playing before your scene is on the screen.
You will have problems later when you re-enter the scene with loading the sound in the main chunk of the module and then disposing it. But none of that has anything to do with this error.
Are there any other errors in the console log that might clue us in?
I would guess that particular error is probably related to a bad sound file. Corona SDK only supports a 11,025 hz, 22Khz and 44Khz sounds. If your bit rate is different it might cause a problem. The file could just be corrupt. The "sound_decode" tells me it's having a problem decoding the sound which is where this error is likely.

Related

Scanner (Ivanti) VELOCITY ver. 2.1.8, adding an error beep while scan an object, which is not counted in store/warehouse

community!
I use ZEBRA MC3300/android 8.1
I would really appreciate if you'll help me with one question.
The main reason I want to do it is to reduce amount of human error possibly can happen.
When VELOCITY app is on and a worker scans a barcode, there is usually plays a beep sound.
But the problem is that if a worker scans wrong barcode or an object, that is not counted in store, usually the same sound plays.
So I tried to edit this via console.
so, basically, the sound I've added works fine, but an error beep isn't playing when I try to scan any random(not our) object's barcode.
Is there a solution for my problem?
Sorry if my code looks too silly, I'm just trying to improve my workspace :(
Thanks in advance!
function replaceBeep(beepType,soundFile) {
function onBeep(event) {
if(event.type == beepType)
{
Device.beepPlayFile(soundFile);
event.eventHandled = true;
}
}
WLEvent.on("Beep", onBeep);
Device.errorBeep(1000, 300, 50, 0.5);
}
WLEvent.registerScope("session",replaceBeep,null,["2","error.wav"]);`
expecting to play separate beep sounds for wrong and right scan.

In Corona SDK composer, when I reload a scene, audio slightly fades out

In my Corona SDK project, I have a composer scene called "menu.lua" (created with composer.newScene()) that is the first scene, called by main.lua file. I have a background track only for this scene, loaded in scene:create() with audio.loadSound() in a local variable. When I load another scene (let's suppose it's a "credit" scene, static, with no music, sounds, animations, timers, etc.) and then come back to menu scene, audio is still played, but with a lower volume.
Audio is played in loop on channel 2, I use audio.play() in scene:show "did" phase. I use audio.fadeOut() in scene:hide "will" phase, and stop it with audio.stop() in "did" phase, then dispose it with audio.dispose() in scene:destroy.
In "menu.lua" file
local composer=require("composer")
local scene=composer.newScene()
local theme --this is the variable for audio
function scene:create(event)
local sceneGroup=self.view
theme=audio.loadSound("sfx/theme_short.mp3")
end
function scene:show(event)
local sceneGroup=self.view
if event.phase=="will"
audio.play(theme,{loops=-1,channel=2})
end
end
function scene:hide(event)
local sceneGroup=self.view
if event.phase=="will" then
audio.fadeOut(theme,{500})
end
elseif event.phase=="did" then
audio.stop(2)
end
end
function scene:destroy(event)
local sceneGroup=self.view
audio.dispose(theme)
end
The other scene (let's suppose it's "credits.lua") is called by a button with a "tap" event attached. In "credits.lua" I use this function to go back to "menu.lua" scene (function is called with a "tap" event attached to a button)
local function goMenu()
composer.removeScene("menu")
composer.gotoScene("menu","slideUp",500)
return true
end
I've already tried to play audio in scene:show "did" phase and in scene:create, but the problem persists. The problem happens with all the scenes, all static (3 in total). Any idea?
You should replace
audio.fadeOut(theme,{500})
with
audio.fadeOut( { channel=2, time=500 } )
since you use wrong syntax.
See audio.fadeOut()
Make sure you read the "Gotcha" section of the docs:
When you fade the volume, you are changing the volume of the channel. This value is persistent and it's your responsibility to reset the volume on the channel if you want to use the channel again later (see audio.setVolume()).
You're responsible for setting the channel volume back because fadeOut changes the volume of the channel.

Google Cast Video Player becomes unresponsive after network error

I am working on a Chromecast custom receiver app, built on top of the sample app provided by Google (sampleplayer.CastPlayer)
The app manages a playlist, I would like the player to move on to the next item in the list after a video fails to play for whatever reason.
I am running into a situation where, after a video fails to load because of a network error, the player becomes unresponsive: in the 'onError_()' handler, my custom code will do this
var queueLoadRequest = ...
var mediaManager = ...
setTimeout (function(){mediaManager.queueLoad(queueLoadRequest)}), 5000
...the player does receive the LOAD event according to the receiver logs, but nothing happens on the screen, the player's status remains IDLEand the mediaManager.getMediaQueue().getItems() remains undefined. Same result trying to use the client controller to try to load a different video.
I have tried to recover with mediaManager.resetMediaElement() and player.reset() in the onError_ handler, but no luck.
For reference, here is a screenshot of the logs (filtered for errors only) leading up to the player becoming unresponsive. Note that I am not interested in fixing the original error, what I need to figure out is how to recover from it:
My custom code is most likely responsible for the issue, however after spending many hours + stripping the custom code to a bare minimum in an effort to isolate the responsible bit of code, I have not made any progress. I am not looking for a fix but rather for some guidance in troubleshooting the root cause: what could possibly cause the Player to become unresponsive? or alternatively how can one recover from an unresponsive Player?

AUDIO_OUTPUT_FLAG_FAST denied by client OR E/MediaPlayer: Error (1,-19)

I am creating a game using Libgdx. I have a lot of small sounds files in the MP3-format and since it is so many I do not preload them. I only load the sound I want to play when it is to be used, like this:
actorSound = Gdx.audio.newSound(Gdx.files.internal(sound));
The code above works great, but the rest of my sounds do not unfortunately. The actor above has its own class and plays a different sound every time it is touched.
When I try to play sounds in my Gamescreen I get the following error:
AUDIO_OUTPUT_FLAG_FAST denied by client
All the audiofiles have the same properties and have been recorded using the same microphone & Audacity. The files are all 44100Hz and only a few kb in size each.
I wonder why the sounds the Actor plays work and the other sounds do not?
I decided to try to change the non-working sounds to music instead and now they play fine - for a little while that is. I can play a full game, return to the menu and start a new game again. The second time I start a game I only get 3 sounds from the Gamescreen and then it is silent except for the sounds from the actor. The error that appears looks like this:
E/MediaPlayer: Error (1,-19)
I load the Music just the same way as the Sound:
gameSound = Gdx.audio.newMusic(Gdx.files.internal(soundeffect));
I have looked into the two errors by reading posts like these:
AUDIO_OUTPUT_FLAG_FAST denied by client
Mediaplayer error (-19,0) after repeated plays
But I'm not sure what to do or change to solve my problem. I would prefer Sound if that is possible, but Music is an acceptable workaround...
When it comes to Music it is probably as suggested in the URL, that I do not release the media players. I am not sure how to do that?
When I leave the GameScreen for another screen, like the MenuScreen or RewardScreen, I dispose Music first. The other screens use Music as well and the sounds are loaded when needed. When I change back to the GameScreen I dispose again and then start a new game...
Any ideas or suggestions? Any help is greatly appreciated.
I added AssetManager as suggested, and I now have a loding screen that loads all the sounds. I load them as sounds and not music, which is how I prefer it.
The sounds work well in the actual game but once I get to the reward screen, only the first sound plays and after that the app crashes with the following error:
06-02 07:47:09.774 6208-6282E/AndroidRuntime: FATAL EXCEPTION: GLThread 2935
Process: PID: 6208
java.lang.NullPointerException: Attempt to read from field 'com.badlogic.gdx.assets.AssetManager
Assets.Assets.manager' on a null object reference
at DelayedSounds(RewardsScreen.java:538)
at RewardsScreen.Update(RewardsScreen.java:567)
at Screens.RewardsScreen.render(RewardsScreen.java:577)
at Game.render(Game.java:46)
at com.badlogic.gdx.backends.android.AndroidGraphics.onDrawFrame(AndroidGraphics.java:459)
at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1562)
at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1262)
06-02 07:47:13.823 6208-6208 E/AndroidGraphics: waiting for pause
synchronization took too long; assuming deadlock and killing
The DelayedSounds method looks like this:
public void DelayedSounds(){
timer = timer + Gdx.graphics.getDeltaTime();
if(playitem == true && timer > 2){
itemsound = "vinster/" + item + ".mp3";
assets.manager.get(itemsound, Sound.class).play(volume);
//sound = Gdx.audio.newMusic(Gdx.files.internal(itemsound));
//sound.setVolume(volume);
//sound.play();
playitem = false;
}
if(playkeep == true && time > 3){
assets.manager.get("dialog/VINSTEN.mp3", Sound.class).play(volume);
//sound = Gdx.audio.newMusic(Gdx.files.internal("prizes/prize.mp3"));
//sound.setVolume(volume);
//sound.play();
playkeep = false;
}
}
As can be seen I use AssetManager now, and have commented out my old code for testing purposes. I define AssetManager in my main class and then pass it around to all other classes that uses sounds.
The RewardsScreen will only play the first sound and then it crashes on a NULL object reference as it seems.
If I change my code back to using Music in the RewardsScreen it works fine (see the code that is commmented out)
The sound I try to play is exactly the same in both cases. Assets class that handles the loading of all my assets has the sounds included and since I still get a NULL object I assume one or more items fails to load?
I search the logs and find this where it loads the sounds:
06-02 08:05:09.360 9844-9888/E/WVMExtractor: Failed to open libwvm.so: dlopen failed: library "libwvm.so" not found
06-02 08:05:09.395 9844-9888/ E/NdkMediaExtractor: sf error code: -1010
06-02 08:05:09.395 9844-9888/ E/SoundPool: Unable to load sample
Maybe this is related to my problem?
I load all the sounds in the same manner and most definitely seem to work, the loading is the regular:
manager.load("prizes/cash.mp3", Sound.class);
I still find the AUDIO_OUTPUT_FLAG_FAST denied by client in my logs but now the sounds are playing instead of being rejected.
Any more ideas about how to solve this?
Your link having enough information for your bug.
It's not good way to create Resource instance each time in Game, Create once and user All over your game, if possible use AssetManager.
Like create Music instance in onCreate() method of your game.
gameSound = Gdx.audio.newMusic(Gdx.files.internal(soundeffect));
Music having play(), resume() and many other helpful methods.
You can also take a look of this, it may be helpful.

Corona: Audio does not begin playing again after scene is re-created

I am trying to play background sound, only during one scene. When this scene is destroyed, the sound should fade out and then stop. Then when the scene is re-created, the sound should start playing again.
Here is what I am trying:
local backgroundMusic
local backgroundMusicChannel
local function stopSound(event)
audio.stop(event.channel)
audio.dispose(event.handle)
backgroundMusic = nil
end
function scene:create(event)
backgroundMusic = audio.loadSound("music/intro.mp3")
backgroundMusicChannel = audio.play(backgroundMusic, {loops = -1, fadein = 3000, onComplete = stopSound})
end
function scene:destroy(event)
audio.fadeOut({channel = backgroundMusicChannel, time=2000})
end
The sound plays when the scene is created initially, and fades out correctly, but does not start again when the scene is created again.
When I change the destroy function to:
function scene:destroy(event)
audio.fadeOut({channel = backgroundMusicChannel, time=2000})
audio.stop(backgroundMusicChannel)
end
the sound does not fade out, because it stops immediately, but it DOES start again correctly the next time the scene is created.
I have also tried using audio.stopWithDelay, which fades out correctly, but similarly, does not begin playing again when the scene is created once more.
If anyone has any insights on what's going on here please let me know!
Could the problem be you cannot (re)play the sound if it isn't stopped yet?
You also never dispose of the audio when the scene ends.
Inside create, stop the previous audio if it already exists.
You're better off creating the sound once and reusing it when needed.
If you use loadStream, you'll have to use audio.rewind() after playing it.
The documentation on this also states that you should probably use loadStream:
https://docs.coronalabs.com/guide/media/audioSystem/index.html

Resources