应用从暂停状态返回后,无法从AVPlayer播放

问题描述

除了从挂起状态返回后,我有一个AVQueuePlayer可以正常运行。

正在播放HLS音频流。我的暂停按钮的逻辑非常简单

\\10.0.0.0\some_path

我已经检查了播放器和currentItem的状态,所有这些都表示它正在“播放”。但是音频无法播放或播放

isPlaying ? player?.play() : player?.pause()

我也在设置会话:

player.rate = 1
player.currentItem.asset.isPlayable = true
player.status == readyToPlay
player.currentItem.status == readyToPlay

AVPlayer won't resume after this

任何有关如何解决此问题的建议将不胜感激。我需要跟踪应用进入暂停状态并重新加载AVPlayerItem吗?

解决方法

我需要跟踪应用进入暂停状态并重新加载AVPlayerItem吗?

这不是您需要跟踪的应用程序暂停;是音频会话的中断。 AVAudioSession为此提供了一个通知。