Adding airplay support to MPMoviePlayer - ios

Hi i am building iOS application target iOS 5 and above. I am using MPMoviePlayerController to stream movie file. I that player i want to give airplay support.
According to apple documentation
Default Movie players (iOS 4.3 and later) support wireless movie
playback to AirPlay-enabled hardware such as Apple TV. The movie
player presents a control that allows the user to choose
AirPlay-enabled hardware for playback when such hardware is in range.
It seems that by default it will display airplay button in fullscreen mode if any airplay device is in range. But it is not seems to be happening. I am unable to see airplay button in movie player.
Am i missing something? Please advise.

By default, MPMoviePlayerController enables AirPlay support. If you haven't set it as FALSE. Then, probably you need to check your network or AppleTV's network connection. They need to be in same network (intranet usually).
There is a safe way to detect whether your iOS device is able to find AppleTV. You can double click HOME button, swipe task bar from left to right side, if you can see "Airplay" route button, then you can reach it. Otherwise, you need to check your AppleTV setting to make sure Airplay function is enabled and AppleTV is connected to same network that you iOS device in.
If you are using your own customized video play controller interface, you can embedded the "Airplay" button into your own UI.
MPVolumeView

Related

How to make an app to play ringer with behaviors similar to iphone native phone ring

I am working on a VOIP app on iOS. I have encountered some problems when implementing "Ignore incoming ringer" feature. It has the following requirements:
1. Should stop ringer if pressed screen lock or volume button
2. Should stop ringer if mute button is pushed to "mute" state
3. Should not play ringer if mute button is in "mute" state
Since iOS SDK provide no information of the phone's hardware buttons, I can only rely on setting AVAudioSession category. Before playing ringer, I set the category to ambient so screen lock and mute button can stop the audio. But this method cannot satisfy my requirements because app cannot play ringer when in background because ambient category cannot support background audio.
In order to solve this problem, I start playing the ringer in playbackandrecord category to make the audio stream come out and change the category to ambient immediately. Though it can meet my requirements, but this method caused many problems and bugs. For exameple, MPVolumeView cannot display the output devices correctly.
Can anyone provide a more elegant way way to simulate ringer? Or can this be done in iPhone? Since it will be in app store, I cannot use private apis. Thanks in advance.

Want to stream my application view on Apple TV using AirPlay Apl in ios sdk?

I want to stream my application on APPLE TV using AirPlay API.? How to use that?
Can it work through iPhone and iPad both?
If yesy please share some doc regarding or demo for the same
You can implement support for external displays very easily. Here is one blog post about it by Matt Gemmell: http://mattgemmell.com/2010/06/01/ipad-vga-output/
If the user enables AirPlay (by clicking the home button twice and then swiping left to reveal the AirPlay shortcut) with an Apple TV, your app will detect one additional screen, the Apple TV. You can then use the API described in the blog post above to stream your app's view to the Apple TV.
There is no way I know of to add an AirPlay button directly in your app, though.

iPad application - Mirroring the app in airplay

I've a kids application which is rich in graphics.
It don't have any videos in it. Only background audio will be there
It has some activities like counting numbers, reading alphabets etc.
Can I mirror the application in apple tv using airplay so that what ever they see on iPad app must be shown on TV also?
I googled a lot... but i couldn't find any code. But I read that its possible. Can some one guide in how to proceed with this feature?
To use AirPlay your application does not necessarily have to do anything special. AirPlay is built-into iOS, and any app or game can take advantage of it. The user simply has to double-tap the Home button, swipe to the left, press the AirPlay button and select the mirroring option. This works for all apps automatically, including video and sound.

Purpose of mediaPlaybackAllowsAirPlay property on UIWebView

The UIWebView Class Reference describes mediaPlaybackAllowsAirPlay as follows:
A Boolean value that determines whether Air Play is allowed from this view.
When the mediaPlaybackAllowsAirPlay is set to YES:
If on my iPad I load a YouTube or Vimeo video to a UIWebView with this set to it's default value of YES and play the video while mirroring to an AirPlay device, the video signal is sent to the AirPlay device and takes over the AirPlay device screen and "TV Connected / This video is playing on the TV" is displayed in the UIWebView on the AirPlay. This is the behavior I would expect.
When the mediaPlaybackAllowsAirPlay is set to NO:
I get exactly the same behavior as above. What I expected is that if the UIWebView mediaPlaybackAllowsAirPlay was set to NO, that instead of sending the video signal to the AirPlay device, even if the iPad is mirroring, the video would simply play inside the UIWebView on the iPad.
Has anyone used this property to create two different functional behaviors and what were they?
As far as I can tell, this property has no impact on the playing of AirPlay media.
It appears that the mirroring mode is taking precedence over the mediaPlaybackAllowsAirPlay flag.
If I'm interpreting the documentation correctly, mediaPlaybackAllowsAirPlay only allows the user to send the data to a particular airplay compatible device. If it is disabled, the airplay selector simply doesn't show up.
If this is a bug to you, please head over to http://bugreporter.apple.com and let Apple know.

Set Airplay manually?

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

Resources