• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

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

[复制链接]
菜鸟教程小白 发表于 2022-12-12 14:46:42 | 显示全部楼层 |阅读模式 打印 上一主题 下一主题

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

我在 Apple TV 上进行测试,音频播放良好,但始终使用最大音量,我无法更改。音量 slider 被禁用,我不明白为什么会这样,因为它可以在其他应用中使用。

enter image description here

例如,我可以在 Overcast 中更改预期的音量,并且音频不会以最大音量开始:

enter image description here

我做错了什么?我是否缺少任何选项。

更新:

我正在使用 AVPlayer 并且 allowsExternalPlayback 属性为 true。

更新 2:

MPVolumeView也会出现同样的问题。

一些 Reddit 用户告诉我“假设一个人会使用输出设备(电视、音响系统等)的音量控制来控制音量。”、“就像当你通过 hdmi 将 MacBook 插入电视”,这是有道理的,但我怎么能强制不使用输出设备来控制音量?它在其他播客应用中的工作方式与我预期的一样。



Best Answer-推荐答案


在与 DTS 工程师讨论后,他找到了解决方法 (rdar://42881405 当使用 AirPlay 连接到 Apple TV 时,音量控制被禁用)。

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

However, AVAudioPlayer cannot play streamed assets, so it may not be a viable solution in your use case. I’m still researching whether the audio-only behavior can be obtained for other playback techniques."

解决办法:

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

最后说明:

即便如此,我认为使用新的 AVSampleBufferAudioRendererAVSampleBufferRenderSynchronizer 类也可以,但设置起来要复杂得多。

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

关于ios - AirPlay:连接到 Apple TV 时音量控制被禁用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51596277/

回复

使用道具 举报

懒得打字嘛,点击右侧快捷回复 【右侧内容,后台自定义】
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关注0

粉丝2

帖子830918

发布主题
阅读排行 更多
广告位

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap