MPNowPlayingInfoCenter nowPlayingInfo 通过 AirPlay 忽略 AVPlayer 音频

发布于 2024-12-25 20:58:49 字数 441 浏览 4 评论 0原文

我已经使用 AVPlayer 实现了音频播放,播放远程 mp3 url。

我想使用 MPNowPlayingInfoCenter nowPlayingInfo 方法显示有关当前播放音频的信息。

当我锁定屏幕时,我确实看到了我设置的图像和标题,所以我知道这个方法正在以某种方式注册信息,但是当我切换到 AirPlay 到 AppleTV 时,显示看起来像通用视频输出,带有底部的进度条,但正确显示了经过的时间和持续时间。

如果我设置了相同的 nowPlayingInfo,但随后使用 AudioQueue 启动一些音频,那么它会在一半屏幕上正确显示图像(看起来就像使用 iPod/音乐应用程序播放播客一样)。

这是否只是使用 AVPlayer 对音频的 AirPlay 支持的限制,或者是否有某种方法可以让它正确显示图像和信息?

I have implemented audio playback using AVPlayer, playing a remote mp3 url.

I want to display the information about the currently playing audio using the MPNowPlayingInfoCenter nowPlayingInfo method.

When I lock the screen, I do see the image and title I set, so I know that this method is registering the information in some way, but when I switch to AirPlay to an AppleTV, the display looks like a generic video output, with the progress bar at bottom, but elapsed time and duration correctly displayed.

If I set this same nowPlayingInfo, but then start some audio using an AudioQueue, then it properly displays the image on half the screen (it looks just like playing a podcast with the iPod/Music app).

Is this just a limitation of AirPlay support for audio using AVPlayer, or is there some way to get it to display the image and info properly?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

感情旳空白 2025-01-01 20:58:49

好的 - 我浏览了苹果开发论坛并找到了提示。

如果您仅将 AVPlayer 用于音频,并希望它在播放时在后台工作,则需要禁用 allowsAirPlayVideo 设置。

显然,iOS 5+ 上的 AVPlayer 假定它正在通过 AirPlay 播放视频,因此不允许后台播放,除非您明确禁用视频 AirPlay。

一旦禁用此功能(即 self.player.allowsAirPlayVideo = NO;),您的音频仍将通过 AirPlay 播放,但现在它将正确显示音频/iPod 之类的界面。

Ok - I dug through the apple dev forums and found a hint.

If you are using AVPlayer for audio only, and want it to work in the background while doing airplay, you need to disable the allowsAirPlayVideo setting.

Apparently AVPlayer on iOS 5+ assumes that it is playing back video via AirPlay, and so does not allow backgrounding, unless you explicitly disable video AirPlay.

Once you disable this (i.e. self.player.allowsAirPlayVideo = NO;) then your audio will still play via AirPlay, but now it will now show the audio/ipod like interface correctly.

与他有关 2025-01-01 20:58:49

如果您使用的是 iOS7,则必须禁用外部播放:

self.player.allowsExternalPlayback = NO;

If you're on iOS7 you've got to disable external playback :

self.player.allowsExternalPlayback = NO;

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文