Post

Replies

Boosts

Views

Activity

Setting playbackRate in MusicKit for Swift (beta)
Hi! I'm trying out the new MusicKit for Swift (iOS 15 beta). Really liking it! But I'm seeing a weird issue with setting state.playbackRate to anything other than 1.0 when playing. The issue appears to be that the player keeps trying to reset itself to a playbackRate of 1.0. If I set it to 0.5 or 2.0 it still plays the track back at a playbackRate of 1.0. Strangely, about 5% of attempts to change it are actually successful on the ApplicationMusicPlayer. SystemMusicPlayer changes more reliably at maybe a 20% success rate, in my testing. It seems to be happening during/after preparing the track. If I swap out the player's queue while it's preparing to play, I can get it to reliably throw a prepareToPlay error and, upon doing so, it then accepts the playbackRate change to a non-1.0 value. I've tried setting the playbackRate before playing, after playing, and even both! Through observing the playbackRate property I can see that my alterations seem to stick for maybe 0.5 sec as the track loads, then the rate changes back to 1.0 as the song begins to play. I understand it's still in beta so if the answer is simply "wait for release" then that's fine! But I'd like to know if anyone has found a way to reliably alter the playbackRate, as I'm in the middle of scouting a new project that will depend on it. Some detail into my setup: I'm doing this in the WWDC21 project UsingMusicKitToIntegrateWithAppleMusic (which didn't compile out of the box for me until I reworked some of it). My setup is: iPadOS 15 beta 5 (19a5318f) on an iPad Air 2. Xcode v13.0 beta 5 (13A5212g). MacOS Big Sur 11.4. Thanks!
1
0
1.5k
Aug ’21