Frage

My audio won't play unless its finished playing even if I stop it then play it.So if you play the sound and play it again before the sound clip reaches the end, won't play again. How can I make it play and start from the beginning even if its still playing.

-(void)playSound{

[avplayer stop];
[avPlayer play];

}
War es hilfreich?

Lösung

As per the documents -

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.

Set the currentTime property to 0.0 before playing again.

-(void)playSound{

[avplayer stop];
avplayer.currentTime = 0.0;
[avPlayer play];

}
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top