1

I have an iPad app and I have a video playing in a view. I would like to play video using Airplay but by pressing my own button.

I have set allows airplay = YES and so forth, this works if I enable the full controls, but I want to set no controls and have my own button to play the video using Airplay.

So far, I have found no information that would allow me to play a video on AppleTV without allowing the normal controls.

So just using an UIButton action to force the airplay, or at least get available devices and set it manually. Anything that would allow me to do this.

Trausti Thor
  • 3,722
  • 31
  • 41

2 Answers2

3

MPVolumeView will only control audio, it won't control video. For that you'd need iOS 5's AVPlayer, or a movie controller.

An alternative for you might be to use AirplayKit, a 3rd party library. https://github.com/rothacr/AirplayKit

quellish
  • 21,123
  • 4
  • 76
  • 83
  • Not exactly the answer I was after. But the airplay kit is awesome. Thanks a bunch – Trausti Thor Jan 27 '12 at 13:07
  • To be a little clearer then: Using the apple provided API, there isn't a way to show your video on an AirPlay screen without the normal (apple provided) controls. This means that the user has to opt-in by either the use of the MPMoviePlayer controls, or using the iOS 5 mirroring controls (which would allow you to draw on the AirPlay screen as an additional UIScreen (see https://github.com/quellish/AirplayDemo) or using an AVPlayer). AirPlayKit, though, allows you to find available AirPlay devices and send them data, without having the user opt in through the Apple AirPlay UI. – quellish Jan 28 '12 at 02:46
1

To answer my own question.

This is quite possible without jailbreak.

Here is apple's own page explaining this, so this will pass the review process.

Apple developer library document explaining how to do this

Trausti Thor
  • 3,722
  • 31
  • 41
  • This solution requires you to add the whole `MPVolumeView`. Your question was how to trigger the popover from a custom button. – Mark Adams Jan 24 '12 at 10:58
  • That documentation only shows how to allow your content to be played over Airplay. Actually choosing if Airplay is used is a user choice, not a developer choice. So having your own buttons to force Airplay playback like you ask in your opening post, is like Mark Adams mentioned, currently not possible. – Joris Kluivers Jan 24 '12 at 11:13
  • 2
    MPVolumeView *volumeView = [ [MPVolumeView alloc] init] ; [volumeView setShowsVolumeSlider:NO]; [volumeView setShowsRouteButton:YES]; [volumeView sizeToFit]; [someView addObject:volumeView]; [volumeView release]; – Trausti Thor Jan 27 '12 at 12:52
  • 1
    The above code will give you only one clickable view that contains the AirPlay button, so you can put this anywhere in your view, in any view – Trausti Thor Jan 27 '12 at 12:53