开发者

re-playing audio and animation if the view is changed

I have a view that plays an animation and an audio clip. if the user leaves the view and then returns the audio replays from the point where they left the view.

I simply want the audio and the animation to start over as if it was their first time coming to the view.

I thought I had solved it with the开发者_如何学Python following code:

-(void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
[theAudio stop];
[self firstAnimation];

}

so the audio would stop and the animation would stop. then the viewDidLoad would load it all up on the users next visit.

I can't seem to find a solution. I'm sure it's a simple fix. any help would be great.


I am assuming you are using AVAudioPlayer. The documentation for the -stop method is pretty clear:

The stop method does not reset the value of the currentTime property to 0. In other words, if you call stop during playback and then call play, playback resumes at the point where it left off.

So, you should reset currentTime to 0.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜