【问题标题】:Facebook, Spotify (iOS) using MPVolumeView or custom view to bring airplay?Facebook、Spotify (iOS) 使用 MPVolumeView 或自定义视图带来 airplay?
【发布时间】:2016-11-15 21:38:27
【问题描述】:

我正在开发一个 voip 应用程序并希望将音频路由到蓝牙。我了解到唯一的方法是使用 MPVolumeView 调出播放菜单。 MPVolumeView 的缺点是它不是非常可定制的。我查看了 facebook 和 spotify Outlook 应用程序,发现他们都对它进行了自定义,而不是 MPVolumeView API 提供的内容。我想知道他们是否真的在使用 MPVolumeView 或者具有自定义视图并以编程方式将点击事件发送到 MPVolumeView 内的按钮?

【问题讨论】:

  • 你有什么发现吗?我自己也处于一种情况,我一直在寻找这个问题的答案。

标签: ios facebook spotify airplay mpvolumeview


【解决方案1】:

这可能会有所帮助:您可以像 Spotify 应用程序一样通过检查当前音频会话路由并使用 MPVolumeView 上的 routeButtonImage 定制器 API 来更改按钮的图像。

let audioSession = AVAudioSession.sharedInstance( )
if let output = audioSession.currentRoute.outputs.first
{
    let myCustomImage = <#Use information from the output (AVAudioSessionPortDescription) to set a custom image #>
    myVolumeView.setRouteButtonImage( myCustomImage, for: .normal )

}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-04-18
    • 1970-01-01
    • 2011-08-09
    相关资源
    最近更新 更多