调用 stop 后从头开始播放 AvAudioPlayer 文件
Play AvAudioPlayer file from beginning after stop is called
Apple 文档是这样说的:
Discussion
Calling this method, or allowing a sound to finish playing, undoes the setup performed upon calling the play or prepareToPlay methods.
Discussion
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.
在使用[mySound stop]
停止声音文件后,如果文件在上一个会话中没有完全播放,那么在使用[mySound play]
时如何从头开始播放?
我想我的问题是,如何将 currentTime 属性 的值重置为 0?
尝试
AVAudioPlayer *audio = ...;
[audio pause];
audio.currentTime = 0.0;
[audio play];
看看会发生什么。
Apple 文档是这样说的:
Discussion Calling this method, or allowing a sound to finish playing, undoes the setup performed upon calling the play or prepareToPlay methods.
Discussion 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.
在使用[mySound stop]
停止声音文件后,如果文件在上一个会话中没有完全播放,那么在使用[mySound play]
时如何从头开始播放?
我想我的问题是,如何将 currentTime 属性 的值重置为 0?
尝试
AVAudioPlayer *audio = ...;
[audio pause];
audio.currentTime = 0.0;
[audio play];
看看会发生什么。