MPMediaPlayback.currentPlaybackRate no longer working in iOS 15.4?

Just wondering if anyone else is having issues with currentPlaybackRate in release version of iOS 15.4? In my particular case this is using MPMusicPlayerController.applicationQueuePlayer.

I've always had issues controlling this property reliably but from what I can see it is now completely non-operational in 15.4.

I've isolated this behavior in a trivial project, and will file a radar, but hoping others may have some insight first.

FWIW- This is my trivial test case:

class ViewController: UIViewController {
    lazy var player: MPMusicPlayerApplicationController = {
        let player = MPMusicPlayerController.applicationQueuePlayer
        player.repeatMode = .none
        player.shuffleMode = .off
        player.beginGeneratingPlaybackNotifications()
        return player
    }()

    override func viewDidLoad() {
        super.viewDidLoad()

        NotificationCenter.default.addObserver(forName: .MPMusicPlayerControllerPlaybackStateDidChange, object: nil, queue: .main) { [weak self] notification in
            guard let notificationPlayer = notification.object as? MPMusicPlayerApplicationController,
                  notificationPlayer === self?.player else {
                return
            }
            
            debugPrint("Player state now: \(notificationPlayer.playbackState)")
        }
    }

    @IBAction func goAction(_ sender: Any) {
        guard let item = MPMediaQuery.songs().items?.randomElement() else {
            debugPrint("Unable to access media items")
            return
        }

        debugPrint("Now playing item: \(item.title ?? "")")
        player.setQueue(with: [item.playbackStoreID])

        player.prepareToPlay() { error in
            guard error == nil else {
                debugPrint("Player error: \(error!.localizedDescription)")
                return
            }

            DispatchQueue.main.async { [weak self] in
                self?.player.play()
            }
        }
    }

    @IBAction func slowAction(_ sender: Any) {
        debugPrint("Setting currentPlaybackRate to 0.5")
        player.currentPlaybackRate = 0.5
        checkPlaybackRate()
    }

    @IBAction func fastAction(_ sender: Any) {
        debugPrint("Setting currentPlaybackRate to 1.5")
        player.currentPlaybackRate = 1.5
        checkPlaybackRate()
    }

    func checkPlaybackRate(afterSeconds delay: TimeInterval = 1.0) {
        DispatchQueue.main.asyncAfter(deadline: .now() + delay) {
            debugPrint("After \(delay) seconds currentPlaybackRate now: \(self.player.currentPlaybackRate)")
        }
    }
}

Typical console output:

"Now playing item: I Know You Know"
"Player state now: MPMusicPlaybackState(rawValue: 2)"
"Player state now: MPMusicPlaybackState(rawValue: 1)"
"Setting currentPlaybackRate to 1.5"
"After 1.0 seconds currentPlaybackRate now: 1.0"
"Setting currentPlaybackRate to 0.5"
"After 1.0 seconds currentPlaybackRate now: 1.0"

Replies

I can also confirm that setting the currentPlaybackRate doesn't work on iOS 16.1 beta 1.

Please, we don't want a repeat of the horrible time we had six months ago, our users were crazy.

  • Same problem with iOS 16.1 beta 2

Add a Comment

FWIW, my feedback was resolved with "potential fix identified for an upcoming OS release." Hopefully that means a subsequent 16.1 beta and not 16.2.

I've tried 16.1 beta 3 and unfortunately the bug is still there. @JoeKun any news on this problem?

Hi all, beta 4 fixed it! Nicolas

Hello @nickfromsf, @florom, @umbertoide, @xalio,

Thank you all for bringing attention to this issue.

Indeed, we accidentally regressed the functionality of the currentPlaybackRate property for playback of Apple Music content in earlier beta builds of iOS 16.1.

As @xalio pointed out, we fixed that up in the latest beta build of iOS 16.1, which is beta 4 for iPhone (build number 20B5064c).

I hope this helps.

Best regards,

  • Thanks for following up, back to normal now!

  • Thank you so much for the followup JoeKun; it’s absolutely appreciated :)

  • Thank you very much, tried the new version this morning and can confirm it works!

Hey @JoeKun,

I'm on iOS 16.4 and assigning to ApplicationMusicPlayer.state.playbackRate doesnt seem to make any change to the playback rate... I guess it's a bug, right?

  • I've been testing with all releases since we had this issue in 16.1 and the issue where playback rate stopped working has not reoccured for me, I use it regularly on 16.4.1.

  • Hmm, and you use ApplicationMusicPlayer specifically @nickfromsf 🤔? Well, obviously it can be something on my side, but the code that I use is pretty simple (you can see the gist that I shared in the feedback here)

Add a Comment

Hello @Czajniks,

I don't know yet.

Would you mind filing a new ticket on Feedback Assistant to track the issue you're encountering? Please make sure to include a sysdiagnose and an approximate timestamp of when your app exercised this code path that lead to changing the ApplicationMusicPlayer.state.playbackRate.

Thank you very much in advance.

Best regards,

  • Works OK here with iOS 16.4.1

    Using Obj-C if that matters?

    MPMusicPlayerController *player; self.player = [MPMusicPlayerController applicationMusicPlayer];

    self.player.currentPlaybackRate = newRate;

    Big but: I have tons of hacks to get this working reliable and I cross my fingers every update.

  • Thanks for a rapid response @JoeKun 🙌 Its FB12168694. I'm not entirely sure how should I provide you a sysdiagnose though. Can you give me a bit more guidance on that?

  • Oh man, I can feel your pain @florom. On my side, it's all Swift and the whole app is SwiftUI, DocumentGroup-based (maybe that makes a difference 🤷🏼‍♂️?)

Add a Comment

MPSystemMusicPlayerController.currentPlaybackRate = <someRate> broken (causes hang) still when starting playback. iOS 16.4.1(a). :(

Hello @haarj,

I'm sorry to hear that. Please file a new ticket on Feedback Assistant and make sure to attach a sysdiagnose taken shortly after reproducing this issue. Please also make sure to mention the time when this issue occurred.

Please refer to this document for more information on how to capture a sysdiagnose.

Thank you very much in advance for your help.

Best regards,