Search code examples
iosaudiococos2d-iphone

Check if background music is already playing


There may not be a easy way of doing this outside of using a NSUSERDEFAULT but is there a way to check if the background music is already playing?

I am using

[[OALSimpleAudio sharedInstance] playBg:@"game_loop.mp3" loop:YES];

So is there a way to see if the value is already game_loop.mp3 ? So I am looking to check if the file name is already playing so it doesn't reset when the view is loaded.

I have several background music files that load at certain points so can't just put it in the app delegate.


Solution

  • You can check one of the baseURL, absoluteString or absoluteURL properties of the currently loaded URL in the [OALSimpleAudio sharedInstance].

    [[[OALSimpleAudio sharedInstance] backgroundTrackURL] absoluteString]