iphone - NSOSStatusError -
i try play number of audios in app , working fine upto 3 times. when trying play in 4th time shows error . error domain=nsosstatuserrordomain code=-43 "the operation couldn’t completed. (osstatus error -43.)" .the code
nsurl *url = [nsurl fileurlwithpath:[nsstring stringwithformat:@"%@/sun.wav", [[nsbundle mainbundle] resourcepath]]]; nserror *error; audioplayer = [[avaudioplayer alloc] initwithcontentsofurl:url error:&error]; audioplayer.numberofloops = 0; audioplayer.volume=1.0; if (audioplayer == nil) { nslog([error description]); } else [audioplayer play];
anybody figure out before..?
looks aren't releasing audioplayer object. fact can play 3 times related number of open files can have in avaudioplayer object.
look delegate methods avaudioplayer: specifically
- (void)audioplayerdidfinishplaying:(avaudioplayer *)player successfully:(bool)flag - (void)audioplayerdecodeerrordidoccur:(avaudioplayer *)player error:(nserror *)error
you'll want like
(in main code)
audioplayer.delegate = self;
then add function like
- (void)audioplayerdidfinishplaying:(avaudioplayer *)player successfully:(bool)flag { [player release]; }
i'm sure can figure out rest.
Comments
Post a Comment