AL_INVALID_NAME in playBackgroundMusic

Hi, I got that error in the console (the game keeps running, but without generating any sound) just doing this while following the tutorial in the wiki section (BlackBerry PlayBook / QNX):

CocosDenshion::SimpleAudioEngine::sharedEngine()->playBackgroundMusic(“background-music-aac.wav”, true);

Error loading file: ‘background-music-aac.wav’
AL_INVALID_NAME in playBackgroundMusic
Error loading file: ‘pew-pew-lei.wav’
could not find play sound pew-pew-lei.wav

any idea? Thanks!

ok THERE IS AN ERROR IN THE TUTORIAL (or it is outdated/not tested with QNX). In QNX, unless you pre-initialize the sound files in the constructor (and no somewhere else), it WILL NOT WORK:

CocosDenshion::SimpleAudioEngine::sharedEngine()->preloadBackgroundMusic(CCFileUtils::fullPathFromRelativePath(“background-music-aac.wav”));
CocosDenshion::SimpleAudioEngine::sharedEngine()->preloadEffect( CCFileUtils::fullPathFromRelativePath(“pew-pew-lei.wav”) );

CocosDenshion::SimpleAudioEngine::sharedEngine()->setEffectsVolume(0.5);
CocosDenshion::SimpleAudioEngine::sharedEngine()->setBackgroundMusicVolume(0.5);

Please, add it to the tutorial, it’s confusing and very frustrating… I would do it myself but don’t have permissions to edit it.

Thanks.

Jesus

another error, to play the effect it should be the following:

CocosDenshion::SimpleAudioEngine::sharedEngine()~~>playEffect).c_str);

thanks! I was getting crazy with this! Fortunately I’ve noticed that there is anice cocosdenshion example with the cocos2dx download :~~)

Thanks for posting this, it’s useful in troubleshooting the problem I’m having with BB10. I’ve tried preloading the music and sfx as you suggest, but still I can’t seem to get any audio. I get the same errors:

Error loading file: ‘Audio/Easy_Stroll_alt_mix_mp3.mp3’
AL_INVALID_NAME in playBackgroundMusic

Are there any other gotchas that you discovered whilst getting audio working?

Thanks for your help!

Ben

hi, unfortunately I did not develop for blackberry tablet anymore. Is it a profitable platform?

Jesus Bosch wrote:

hi, unfortunately I did not develop for blackberry tablet anymore. Is it a profitable platform?

Ah no worries then. I’m not sure whether it’s profitable yet; I’m still porting my first game. However, the 10k guarantee is a pretty interesting thing: https://developer.blackberry.com/builtforblackberry/commitment/

After looking through the source it looks like the Blackberry version of cocos2d-x doesn’t support .mp3, so I’m just re-encoding as .ogg to see how that turns out…

Ben

thanks for sharing Ben!

Good luck!

For anybody else who encounters this problem, you’ll need to do the following:

~~Convert all your mp3s to oggs: cocos2d-x on blackberry doesn’t support mp3 yet . Wavs seem to play fine.
~~Run all your audio file references through CCFileUtils::fullPathFromRelativePath() first. This isn’t necessary on other platforms, but it appears to be on Blackberry.
-Preload the music before playing it. Jesus Bosch is correct; it won’t work without doing this.

Ben

Ben, have you tested your application in Simulator or on a real device? I have problems hearing sounds on simulator, although I did everything as you suggested.

Alexander Belchenko wrote:

Ben, have you tested your application in Simulator or on a real device? I have problems hearing sounds on simulator, although I did everything as you suggested.

I’ve only tested on the simulator I’m afraid, although the sound seemed to work fine on it. Can you hear sound on other apps in the simulator?

Ben

Oh, I found that I had to “Connect sound card” in Vmware Fusion. It wasn’t obvious settings hidden in toolbox below a spanner.
But sounds are played with some irks.

Ben, what version of Cocos2dx are you using?

Alexander Belchenko wrote:

Oh, I found that I had to “Connect sound card” in Vmware Fusion. It wasn’t obvious settings hidden in toolbox below a spanner.
But sounds are played with some irks.

Yep, I’ve found that it sometimes skips and stutters on the simulator. At this stage I don’t have hardware, so I’ve no idea whether this is expected behaviour on the simulator or not.

Ben, what version of Cocos2dx are you using?

I’m still on 2.0.3, although I’ve had to make some adjustments. For example, I’ve dropped the latest cocos2dx/platform/blackberry/CCImage.cpp into my project as it fixes some of the text stuff (although text wrapping on CCLabelTTFs still doesn’t work unfortunately).

Which version are you running?

Ben

I’m using 2.0.4, for some reason I skipped 2.0.3, although initially my game was written using 2.0.1.

In the end I’ve got working solution for sound in simulator with following procedure:

  1. I’m using full file path to sound resource as suggested: CCFileUtils::fullPathFromRelativePath(“pew-pew-lei.wav”) and use ogg instead of mp3. (Honestly I didn’t try to play mp3, I simply converted my music to ogg).

  2. preload all effects before playing them with playEffect(). That could be done at the start of the game or scene where they should be used.

  3. For background music you must preload the file you want to play right before you start playing it, and you must stop playing previous track explicitly. This is very important if you want to play different music for different part of your game (e.g. one for menu and other for game scene)

  4. Don’t try to preload all background music at once - you’ll get the latest preloaded track even though you will use different filename (yes, it’s weird). For example:

SimpleAudioEngine::sharedEngine()>preloadBackgroundMusic);
SimpleAudioEngine::sharedEngine
>preloadBackgroundMusic);
SimpleAudioEngine::sharedEngine~~>playBackgroundMusic;
This will play menu.ogg even though I’ve asked for play.ogg~~ this is really weird but it behaves so for me on emulator.
4) If you forgot to stop currently playing background music then you’ll end up with 2 tracks playing simultaneously, but stopBackgroundMusic only stops the latest track.
So, in the end I wrote the following helper function to use instead of SimpleAudioEngine’s playBackgroundMusic:
<pre>
void playBackgroundMusic
{
CocosDenshion::SimpleAudioEngine *s_engine = CocosDenshion::SimpleAudioEngine::sharedEngine;
if )
s_engine~~>stopBackgroundMusic;
s_engine~~>preloadBackgroundMusic(pszFilePath);
s_engine~~>playBackgroundMusic;
}
</pre>
The number of wtf with Blackberry sound easily outperforms issues with sound on Android. %~~/

I hope we can test my port on real device soon.

Good stuff, I’m glad you got it working.

Ben

Can you help me in this…I am new to blackberry development…
I have set up everything but facing problem on integrating cocosdenshion…
I have built Cocosdenshion project in ide and added in the dependency of project properties and also in Add library in project configure…

Still i am getting compile error like this :
C:2dx24\CocosDenshion\proj.blackberry\Simulator/libCocosDenshion.so: undefined reference to `alSourceRewind’
C:2dx24\CocosDenshion\proj.blackberry\Simulator/libCocosDenshion.so: undefined reference to `alutCreateBufferFromFile’
C:2dx24\CocosDenshion\proj.blackberry\Simulator/libCocosDenshion.so: undefined reference to `alGetError’
C:2dx24\CocosDenshion\proj.blackberry\Simulator/libCocosDenshion.so: undefined reference to `alGenSources’
C:2dx24\CocosDenshion\proj.blackberry\Simulator/libCocosDenshion.so: undefined reference to `alSourcePlay’
etc…

And also not found any guide regarding setting Cocosdenshion in blackberry…

Viraj Dasondi wrote:

Can you help me in this…I am new to blackberry development…
I have set up everything but facing problem on integrating cocosdenshion…
I have built Cocosdenshion project in ide and added in the dependency of project properties and also in Add library in project configure…
>
Still i am getting compile error like this :
C:NVPACKCocos2dx24CocosDenshionproj.blackberrySimulator/libCocosDenshion.so: undefined reference to `alSourceRewind’
C:NVPACKCocos2dx24CocosDenshionproj.blackberrySimulator/libCocosDenshion.so: undefined reference to `alutCreateBufferFromFile’
C:NVPACKCocos2dx24CocosDenshionproj.blackberrySimulator/libCocosDenshion.so: undefined reference to `alGetError’
C:NVPACKCocos2dx24CocosDenshionproj.blackberrySimulator/libCocosDenshion.so: undefined reference to `alGenSources’
C:NVPACKCocos2dx24CocosDenshionproj.blackberrySimulator/libCocosDenshion.so: undefined reference to `alSourcePlay’
etc…
>
And also not found any guide regarding setting Cocosdenshion in blackberry…

Not sure if you still need this or not but I ran into this problem as well. In QNX Momentics IDE click on your project and press CTRL+SHIFT+L Choose Standard blackberry libraries, under Multimedia select both OpenAL and OpenAL Utlity Toolkit then rebuild your project

Thanks @Ryan Hentz…
Useful answer or suggestions will always be useful…(either to me or others)…