MPNowPlayingInfoCenter nowPlayingInfo通过AirPlay的忽视AVPlayer音频 [英] MPNowPlayingInfoCenter nowPlayingInfo ignored for AVPlayer audio via AirPlay

查看:1282
本文介绍了MPNowPlayingInfoCenter nowPlayingInfo通过AirPlay的忽视AVPlayer音频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经实现用AVPlayer,打远程URL MP3音频播放。

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

我要显示关于使用 MPNowPlayingInfoCenter nowPlayingInfo 方法当前正在播放的音频信息。

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

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

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.

如果我设置此相同的 nowPlayingInfo ,但使用AudioQueue启动一些音频,然后将它正确地显示一半的屏幕上的图像(它看起来就像玩播客与iPod /音乐应用程序)。

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

时使用AVPlayer的音频支持AirPlay这只是一个限制,或者是有一些方法来得到它来显示图像和信息是否正确?

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?

推荐答案

确定 - 我在苹果开发论坛挖,发现一个提示

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

如果您使用的是AVPlayer纯音频,并希望它在后台工作,而这样做的AirPlay,你需要禁用 allowsAirPlayVideo 设置。

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.

显然AVPlayer在iOS 5+假定它是通过AirPlay的播放视频,所以不允许一个后台,除非你明确禁用视频的AirPlay。

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.

一旦你禁用此(即 self.player.allowsAirPlayVideo = NO; ),那么你的声音仍然可以通过AirPlay的发挥,但现在它现在将显示音频/ iPod的像正确连接。

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.

这篇关于MPNowPlayingInfoCenter nowPlayingInfo通过AirPlay的忽视AVPlayer音频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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