I am trying to detect when an AirPlay device is available on the network and if there is one, I'd like to display a list.

For example, the app "Dailymotion" does exactly what I want : when I connect my iPhone to a network with an Apple TV, an "AirPlay" icon appears : https://dl.dropbox.com/u/4534662/Photo%2004-03-13%2010%2007%2014.png (just next the HD)

And then, when clicking on the AirPlay icon, a picker shows up with the available AirPlay devices : https://dl.dropbox.com/u/4534662/Photo%2004-03-13%2010%2007%2018.png

I didn't find a way to do that with Apple Documentation. So, how can I do that programmatically?

有帮助吗?

解决方案

You can display an AirPlay picker view (if AirPlay is available) like so:

MPVolumeView *volumeView = [ [MPVolumeView alloc] init] ;
[volumeView setShowsVolumeSlider:NO];
[volumeView sizeToFit];
[view addSubview:volumeView];

The MPVolumeView displays all the available AirPlay devices. The code above disables the volume slider, which you may or may not want to do. What you can't do is get programatic access to AirPlay device information.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top