AirPlay:连接到Apple TV时,音量控制被禁用

里卡德佩雷拉

我正在播客应用程序中实现AirPlay支持我添加了一个AVRoutePickerView,AirPlay设备可以正常加载,并且可以成功连接到设备。

我正在Apple TV上进行测试,并且音频播放良好,但是始终使用最大音量,因此无法更改。音量滑块已禁用,我不明白为什么会发生这种情况,因为它可以在其他应用程序中使用。

在此处输入图片说明

例如,我可以更改“预期的覆盖”中的音量,并且音频不是从最大音量开始的:

在此处输入图片说明

我究竟做错了什么?我错过任何选择了吗?

更新:

我正在使用AVPlayerandallowsExternalPlayback属性为true。

UPDATE2:

The same issue happens with MPVolumeView.

Some Reddit users told me "It assumes a person would use the volume control of the output device (TV, sound system, etc) to control the volume.", "Like when you plug a MacBook into a tv via hdmi", and it makes sense but how can I force to not use the output device to control the volume? It works as I expected in other podcast apps.

ricardopereira

After discussion with a DTS Engineer, he found a workaround (rdar://42881405 Volume control is disabled when connected to Apple TV using AirPlay).

"According to engineering, the disabling of the volume control is correct behavior for certain Apple TV configurations, where the audio is being sent to the actual TV via HDMI. In that case, volume is controlled by the TV itself.

An alteration to this standard behavior is made for audio-only apps (such as Podcasts and Overcast). In those cases, the volume control is enabled anyway, and it provides a software volume adjustment of the audio in addition to the hardware volume control. The reason you weren’t getting this is that you used AVQueuePlayer, which is regarded as a video player, not a pure audio player. I modified your sample project to use AVAudioPlayer instead, and the volume control was enabled for AirPlay output as expected.

但是,AVAudioPlayer无法播放流式资产,因此在您的用例中可能不是可行的解决方案。我仍在研究是否可以通过其他播放技术获得纯音频行为。”

解:

基本上,将allowsExternalPlaybackAVPlayer / AVQueuePlayer的属性设置false会禁止将视频播放路由到AirPlay,并且(作为副作用)允许纯音频播放。

最后说明:

即使这样,我认为使用newAVSampleBufferAudioRendererAVSampleBufferRenderSynchronizerclass也可以,但是设置起来要复杂得多。

已创建的rdar:// 42966681:提供用于使用AVPlayer / AVQueuePlayer将应用程序指定为“仅音频”的API

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章