iOS 13.4中的MPMusicPlayerController.applicationQueuePlayer错误 [英] MPMusicPlayerController.applicationQueuePlayer bugs in iOS 13.4

查看:326
本文介绍了iOS 13.4中的MPMusicPlayerController.applicationQueuePlayer错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在Feedback Assistant中提交了有关此问题的反馈,但我也想在此发布-从iOS 13.4开始,我注意到MediaPlayer框架中的各种错误,尤其是applicationQueuePlayer和applicationMusicPlayer.

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]

在调用prepareToPlay()时,此错误随之出现:

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}

最终,在调用了prepareToPlay足够的次数之后,它会变得直截了当并开始播放内容,但是即使如此,我仍然发现我必须多次调用play()或pause()才能可靠地进行操作.

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.

还有其他人在13.4之后的应用中看到此消息吗?

Anyone else seeing this in their apps post-13.4?

推荐答案

在我的情况下,我的播放器逻辑并不总是会触发播放器?.prepareToPlay()代码.我确保停止播放器,然后立即触发prepareToPlay.然后,我为播放器准备"contentsOf:URL",并调整播放器设置,然后播放.由于发生了突然的声音,我还必须添加一些奇怪的音量调整.我将在下面发布我的播放器代码.

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)
    }
}

这篇关于iOS 13.4中的MPMusicPlayerController.applicationQueuePlayer错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆