Jesus Bosch AL_INVALID_NAME in playBackgroundMusic
Posts 367
Location Catalonia
Added by Jesus Bosch 12 months ago

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!

Check my latest cocos2dx game (iPad): Three Little Pigs (free) https://itunes.apple.com/au/app/three-little-pigs-learn-while/id578624548?mt=8 Twitter: @jboschaiguade

Jesus Bosch RE: AL_INVALID_NAME in playBackgroundMusic
Posts 367
Location Catalonia
Added by Jesus Bosch 12 months ago

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

Check my latest cocos2dx game (iPad): Three Little Pigs (free) https://itunes.apple.com/au/app/three-little-pigs-learn-while/id578624548?mt=8 Twitter: @jboschaiguade

Jesus Bosch RE: AL_INVALID_NAME in playBackgroundMusic
Posts 367
Location Catalonia
Added by Jesus Bosch 12 months ago

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

CocosDenshion::SimpleAudioEngine::sharedEngine()->playEffect(std::string(CCFileUtils::fullPathFromRelativePath("pew-pew-lei.wav")).c_str());

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

Check my latest cocos2dx game (iPad): Three Little Pigs (free) https://itunes.apple.com/au/app/three-little-pigs-learn-while/id578624548?mt=8 Twitter: @jboschaiguade

Ben Ward RE: AL_INVALID_NAME in playBackgroundMusic
Posts 75
Location London, United Kingdom
Added by Ben Ward 4 months ago

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

Jesus Bosch RE: AL_INVALID_NAME in playBackgroundMusic
Posts 367
Location Catalonia
Added by Jesus Bosch 4 months ago

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

Check my latest cocos2dx game (iPad): Three Little Pigs (free) https://itunes.apple.com/au/app/three-little-pigs-learn-while/id578624548?mt=8 Twitter: @jboschaiguade

Ben Ward RE: AL_INVALID_NAME in playBackgroundMusic
Posts 75
Location London, United Kingdom
Added by Ben Ward 4 months ago

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

Jesus Bosch RE: AL_INVALID_NAME in playBackgroundMusic
Posts 367
Location Catalonia
Added by Jesus Bosch 4 months ago

thanks for sharing Ben!

Good luck!

Check my latest cocos2dx game (iPad): Three Little Pigs (free) https://itunes.apple.com/au/app/three-little-pigs-learn-while/id578624548?mt=8 Twitter: @jboschaiguade

Ben Ward RE: AL_INVALID_NAME in playBackgroundMusic
Posts 75
Location London, United Kingdom
Added by Ben Ward 4 months ago

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 (at least not that I can see). 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

Alexander Belchenko RE: AL_INVALID_NAME in playBackgroundMusic
Posts 35
Added by Alexander Belchenko 4 months ago

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.

Ben Ward RE: AL_INVALID_NAME in playBackgroundMusic
Posts 75
Location London, United Kingdom
Added by Ben Ward 4 months ago

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

Alexander Belchenko RE: AL_INVALID_NAME in playBackgroundMusic
Posts 35
Added by Alexander Belchenko 4 months ago

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?

Ben Ward RE: AL_INVALID_NAME in playBackgroundMusic
Posts 75
Location London, United Kingdom
Added by Ben Ward 4 months ago

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

Alexander Belchenko RE: AL_INVALID_NAME in playBackgroundMusic
Posts 35
Added by Alexander Belchenko 4 months ago

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:

0) 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).

1) 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.

2) 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)

3) 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(fullName("play.ogg"));
SimpleAudioEngine::sharedEngine()->preloadBackgroundMusic(fullName("menu.ogg"));

SimpleAudioEngine::sharedEngine()->playBackgroundMusic("play.ogg");

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:

 1void playBackgroundMusic(const char* pszFilePath, bool bLoop)
 2{
 3    CocosDenshion::SimpleAudioEngine  *s_engine = CocosDenshion::SimpleAudioEngine::sharedEngine();
 4
 5    if (s_engine->isBackgroundMusicPlaying())
 6        s_engine->stopBackgroundMusic();
 7
 8    s_engine->preloadBackgroundMusic(pszFilePath);
 9    s_engine->playBackgroundMusic(pszFilePath, bLoop);
10}

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.

Ben Ward RE: AL_INVALID_NAME in playBackgroundMusic
Posts 75
Location London, United Kingdom
Added by Ben Ward 4 months ago

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

Ben

Viraj Dasondi RE: AL_INVALID_NAME in playBackgroundMusic
Posts 113
Location India
Added by Viraj Dasondi 2 months ago

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:\NVPACK\Cocos2dx24\CocosDenshion\proj.blackberry\Simulator/libCocosDenshion.so: undefined reference to `alSourceRewind'
C:\NVPACK\Cocos2dx24\CocosDenshion\proj.blackberry\Simulator/libCocosDenshion.so: undefined reference to `alutCreateBufferFromFile'
C:\NVPACK\Cocos2dx24\CocosDenshion\proj.blackberry\Simulator/libCocosDenshion.so: undefined reference to `alGetError'
C:\NVPACK\Cocos2dx24\CocosDenshion\proj.blackberry\Simulator/libCocosDenshion.so: undefined reference to `alGenSources'
C:\NVPACK\Cocos2dx24\CocosDenshion\proj.blackberry\Simulator/libCocosDenshion.so: undefined reference to `alSourcePlay'
etc..

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

Ryan Hentz RE: AL_INVALID_NAME in playBackgroundMusic
Posts 8
Added by Ryan Hentz about 1 month ago

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

Viraj Dasondi RE: AL_INVALID_NAME in playBackgroundMusic
Posts 113
Location India
Added by Viraj Dasondi about 1 month ago

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


(1-16/16)