Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MPMusicPlayerController.applicationQueuePlayer bugs in iOS 13.4

I submitted Feedback about this in Feedback Assistant already, but figured I'd post here too -- as of iOS 13.4, I have noticed various bugs in the MediaPlayer framework, specifically with the applicationQueuePlayer and applicationMusicPlayer.

The first is that on app launch when it initializes, it now throws this error:

[SDKPlayback] applicationQueuePlayer _establishConnectionIfNeeded timeout [ping did not pong]

That error is followed by this one, when prepareToPlay() is called:

Error Domain=MPMusicPlayerControllerErrorDomain Code=6 "Failed to prepare to play" UserInfo={NSDebugDescription=Failed to prepare to play}

Eventually after calling prepareToPlay enough times it'll get its head on straight and start playing the content, but even then I'm finding I have to call play() or pause() several times for it to do so reliably.

Anyone else seeing this in their apps post-13.4?

like image 647
alinder Avatar asked Mar 27 '20 13:03

alinder


Video Answer


1 Answers

In my situation my player logic didn't always fire the player?.prepareToPlay() code. I make sure to stop() the player, then fire the prepareToPlay immediately after. Then I prep the player with the contentsOf: URL, and adjust the player settings, and then play. I also have some weird volume adjustments I had to add because of a popping sound that was happening. I'll post my player code below.

  static func play(sound: Sound) {
    
 
    stop()
    player?.prepareToPlay()

     let path = Bundle.main.path(forResource: sound.file, ofType: sound.extn)
        let url = URL(fileURLWithPath: path!)
    
    do {
        
        player = try AVAudioPlayer(contentsOf: url)
        player?.volume = 0 //starting volume at zero before playing eliminates pop on start
        player?.numberOfLoops = -1
        player?.play()
        player?.setVolume(1, fadeDuration: 0.3)  //fade in, no pop

    } catch {
      print(error)
    }
}
like image 164
Dave Levy Avatar answered Oct 11 '22 19:10

Dave Levy