문제

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];

}
도움이 되었습니까?

해결책

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];

}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top