AVPlayer rate property does not work?

后端 未结 6 598
既然无缘
既然无缘 2020-12-05 05:45

so it would appear that the only values that actually work are 0.0, 0.5, 1.0, and 2.0...

i tried setting it to 0.25 since I want it to play at 1/4th of the natural s

6条回答
  •  我在风中等你
    2020-12-05 05:58

    The play rate restriction appears to be due to pitch correction, which is now configurable in iOS 7 or later.

    // This prevents the play rate from going below 1/2.
    playerItem.audioTimePitchAlgorithm = AVAudioTimePitchAlgorithmLowQualityZeroLatency;
    

    That seems to be the default setting:

    Low quality and very low computationally intensive pitch algorithm. Suitable for brief fast-forward and rewind effects as well as low quality voice. The rate is snapped to {0.5, 0.666667, 0.8, 1.0, 1.25, 1.5, 2.0}.

    The other three algorithm settings let you vary the play rate down to 1/32. For example, AVAudioTimePitchAlgorithmVarispeed turns off pitch correction.

    // Enable play rates down to 1/32.
    playerItem.audioTimePitchAlgorithm = AVAudioTimePitchAlgorithmVarispeed;
    

提交回复
热议问题