Jack Moseley
Jack Moseley

Reputation: 97

AVFoundation AVAudioPlayer stop is pausing - Objective-C

It's fairly hard to show code for this as it is not noticeable in the code. I have some actions like -(IBAction)PlaySound1:(id)sender; and -(IBAction)PlaySound2:(id)sender; and audio files. I have the sounds working all fine. I also have -(void)Stop;. When Play sound 1 is pressed it calls the method Stop and stops sound 2. and the same with sound 2.

The problem I am encountering is when you play sound 1 and stop sound 2, when you play sound 2 it starts from where it left off.

Inside my (void) I have [PlaySound1 stop] //and [PlaySound2 stop]

If anyone could help that would be great. If something was unclear, just comment on this and I'll try and explain it better.

Thanks :)

Upvotes: 2

Views: 608

Answers (1)

Bamsworld
Bamsworld

Reputation: 5680

Stopping an AVAudioPlayer does not reset the play head.

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.

To resume playback from the start set the currentTime property to 0.0 before calling play.

example -

playSound2.currentTime = 0.0;
[playSound2 play];

Upvotes: 1

Related Questions