Unable to Implement Forward Action in AVAudioplayer

前端 未结 2 1839
南方客
南方客 2021-01-15 08:28

I am using AVAudioplayer to play some audio files. I have some controls like forward and rewind.

Rewind is working properly but forward is not.

- (vo         


        
2条回答
  •  别那么骄傲
    2021-01-15 09:29

    The simplest explanation is that cTime ends up either greater than the total time of the audio file or it ends up negative somehow. Both will cause the player instance to set its currentTime property to zero.

    As an aside, I think having the player in a timer's userInfo dictionary is fragile. Unless it just absolutely must be embedded in the timer, I would move it to a property of the class so that all the methods can easily access it. The timer can still call the methods but you won't run the risk of the player being lost while swapping from timer to timer.

提交回复
热议问题