Swift: Trying to control time in AVAudioPlayerNode using UISlider

后端 未结 1 1763

I\'m using an AVAudioPlayerNode attached to an AVAudioEngine to play a sound.

to get the current time of the player I\'m doing this:

         


        
相关标签:
1条回答
  • 2021-01-25 20:55

    I ran into same issue. Apparently the framestoplay was always 0, which happened because of sampleRate. The value for playerTime.sampleRate was always 0 in my case.

    So,

    let framestoplay = AVAudioFrameCount(Float(playerTime.sampleRate) * length)
    

    must be replaced with

    let framestoplay = AVAudioFrameCount(Float(sampleRate) * length)
    
    0 讨论(0)
提交回复
热议问题