ios - AVAudioPlayer is not restarting the bg music? -


i'm on latest xcode version. i'm using following code restart background music. these codes not restarting background music.

nsstring *soundfilepath = [[nsbundle mainbundle] pathforresource:@"game" oftype:@"wav"]; nsurl *soundfileurl = [nsurl fileurlwithpath:soundfilepath]; avaudioplayer *player = [[avaudioplayer alloc] initwithcontentsofurl:soundfileurl error:nil]; [player stop]; player.currenttime = 0; [player play]; 

to use avaudioplayer, need strong reference it. try set player property of controller, use [self.player play]


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

spring cloud - How to configure SpringCloud Eureka instance to point to https on non standard port -

javascript - Bootstrap Popover: iOS Safari strange behaviour -