Swift: Trying to control time in AVAudioPlayerNode using UISlider

后端 未结 1 1764

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)
提交回复
热议问题