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
Post a Comment