Question #1 How do you determine what the player rate is, after command-clicking the fast-forward control?
Question #2 Is there something that needs to be done to keep the audio when manually adjusting the playback rate for 2.0+
Property observing appears to work only for rates below 2.0
Background I am using custom controls (slider and stepper) that are available for the user to manage the speed of playback and keeping both in sync. I am keeping them in sync by obtaining the player rate, using a property observer. Changing the custom control adjusts the play rate and changing the AVKit provided controls changes the custom controls. This works as expected until I command-click the fast-forward control. The property observer reports a play rate of 0, which should mean it is stopped but it is clearly moving forward at a high rate. If I programmatically change the play rate (example, player.rate = 5.0) , the property observer report the rate correctly.
Manual method If you option-click the forward fast-forward control, it increments by 0.1 from 1.0 to 2.0x (1.1, 1.2, 1.3, etc.) and the play rate changes accordingly (property observer reports these values) If you command-click the fast-forward control the play rate changes to 2, 5, 10, 30 and 60x. (Property observer reports 0.0)
How do you determine what the player rate is, after command-clicking the fast-forward control?
The other think is that if I programmatically or manually change the player rate in the range up to 1.9x, the audio continues to play. If I programmatically change the player rate from 2.0x+, the audio continues to play If I manually change the rate (command-click the player fast-forward control) the audio does not continue
Is there something that needs to be done to keep the audio when manually adjusting the playback rate for 2.0+

var playRateSync: Double = 1.0 {
didSet{
// move in specific increment value
let increment = 0.1
let oldValue = playRateSync
let playRateSync = increment * round(oldValue / increment)
let playRateStr = String(format: "%.2f", playRateSync)
playbackLabel.stringValue = "Playback Rate: \(playRateStr)"
playbackSlider.doubleValue = playRateSync
playbackStepper.doubleValue = playRateSync
}
}
func setPlayRateObserver(player: AVPlayer)
{
player.addObserver(self, forKeyPath: "rate", options: [.new, .old, .initial], context: nil)
}
override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) {
print("keyPath: \(keyPath), object: \(object), change: \(change)")
if object as AnyObject? === playerView.player {
if keyPath == "rate" {
print("The real rate: \(Double(playerView.player!.rate))")
if let player = playerView.player
{
if player.rate > 0 {
playRateSync = Double(player.rate)
print("Rate changed. New Rate: \(player.rate)")
}
}
}
}
}
Hello MisterE,
Question #1 How do you determine what the player rate is, after command-clicking the fast-forward control?
There is currently no way to detect the scanning rate after a user as selected fast forward/rewind. If you file a feedback request we will consider modifying this behavior.
Question #2 Is there something that needs to be done to keep the audio when manually adjusting the playback rate for 2.0+
AVKit intentionally disables audio past 2.0x playback to achieve a scanning effect. There is currently no way to enable audio past 2.0x with AVKit.
See our comments in AVPlayer.timeControlStatus and AVPlayer.rate are wrong during fast forward or backward for more details.