Search code examples
cocos2d-iphonesimpleaudioengine

Play background music outside of app bundle using SimpleAudioEngine


I need to play background music residing in the app's document folder (using hosted content downloads which I put in the document folder after download).

It seems that SimpleAudioEngine's way of playing background music is to take a relative path and find it inside the app bundle (CDAudioManager does it):

@"mysong.mp3"

becomes

@"...19E17B5B/myapp.app/mysong.mp3"

Which is not helpful because the file saved into the Documents folder looks like this

@"...19E17B5B/Documents/mysong.mp3"

Edit: It works by specifying something like this @"../Documents/mysong.mp3"

However as we know this would not be recommended/future proof... Any better way to do this?


Solution

  • It works by specifying a relative path like this @"../Documents/mysong.mp3", totally ignoring all recommended ways to get paths :-P