ios4 - iPhone SDK AVAudioPlayer - stop and then fail to start -
- (ibaction)triggersound { if (player == nil) { nserror *error; player = [[avaudioplayer alloc] initwithcontentsofurl:url error:&error]; } else if ([player isplaying]) { [player stop]; player.currenttime = 0; } if (![player play]) { nslog(@"fail"); } }
where player avaudioplayer , action linked uibutton. sound can played, , can played again after sound finish, when press button again during playback, message "fail" logged , sound cannot played, without exception.
i , using ipad ios 4.2.1.
i have noticed audio stream fails play after calling stop(which according reference undoes preparetoplay , play does). instead of calling stop, setting currenttime player.duration(end of stream) worked.
Comments
Post a Comment