3

I want to play a background music and a sound effect on my game. I make the import of SimpleAudioEngine.h and called the methods:

[[SimpleAudioEngine sharedEngine] playBackgroundMusic:@"backgroundMusic.caf"];
[[SimpleAudioEngine sharedEngine] playEffect:@"soundEffect.caf"];

But it doesn't work on iOS 5.1 Simulator neather on an iPod Touch with iOS 5.1 on it. Could be the .caf extension the problem?

Cœur
  • 37,241
  • 25
  • 195
  • 267
douglasd3
  • 761
  • 2
  • 10
  • 27

3 Answers3

2

As far as I remember, audio effects in CocosDenshion are implemented with OpenAL. It works fine with .caf file. Make sure that your .caf files are copied into app bundle. Maybe it simply cannot find file with such name.

Morion
  • 10,495
  • 1
  • 24
  • 33
  • i don't mean xcode. check inside your bundle. you can check bundle content in simulator/applications folder or by using NSFileManager inside your code to determine if such file exists – Morion Sep 05 '12 at 11:51
  • Check in ~/Library/Developer/Xcode/DerivedData/-/Build/Products/Debug-iphoneos/.app - that's the package that is being sent to your iPhone – mrtom Sep 06 '12 at 16:21
  • Even though you see the file in your xCode's project, you might have copied the file without marking your project as the target, try to copy the.caf file again. (that was the solution for me) – the_marcelo_r Sep 14 '13 at 11:15
0

r u import this file...

  #import "SimpleAudioEngine.h" 

if yes then no problem in X-Code.. try any other file or debug your code..

Ayaz
  • 1,398
  • 15
  • 29
0

u should preloadEffect first [[SimpleAudioEngine sharedEngine] preloadEffect: [NSString stringWithUTF8String: pszFilePath]];

mouse
  • 83
  • 1
  • 7