简体   繁体   中英

Facebook, Spotify (iOS) using MPVolumeView or custom view to bring airplay?

I am working on a voip app and want to route audio to bluetooth. I learned that the only way to do is to bring up airplay menu using MPVolumeView. The downside of the MPVolumeView is that it is not very customizeable. I looked at facebook and spotify outlook app and find that they both have customized it more than what is provided by the MPVolumeView API. I am wondering if they are really using the MPVOlumeView or that have a custom view and programatically send tap event to the button inside MPVolumeView?

This may be helpful: you can change the image of the button as the Spotify app does by inspecting the current audio session route, and using the routeButtonImage customizer API on MPVolumeView.

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 )

}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM