Difference between airplay mirroring vs without mirroring - ios

I am trying to do airplay with apple TV. I found out that when I just play video with avplayer without mirroring, I can still play with full screen. However, screen count is only 1 (which is for iPad).
If I do mirroring, the screen count is 2 (one is iPad and one is external monitor). I think without mirroring, screen count should be two also. I am confusing about that. I would like to know more about difference between airplay mirroring vs without mirroring
screens = [UIScreen screens]; //to count screen

The difference is simple.
Mirroring will duplicate everything on your screen and display it on another screen. This is used for things like showing off a photo gallery to a group of people or something like this.
If Mirroring is turned off then this will act as an external display. This is used in games like Real Racing 3 where you can play the game on a TV or something and use your iPhone (iPad) as a controller for the game. The TV and the iPhone will have different things on their screens.

Feel like chiming in as Fogmeister's answer is not all that accurate.
You can easily use mirroring AND have different content on the Apple-TV screen. It is, as far as I've been able to find out, the only way that is supported by any of Apple's public APIs at the moment. A solution has been detailed here among other places.
The idea is to hijack the external window and then give it a viewController which you control (like any other):
if([[UIScreen screens] count] > 1){
UIScreen *secondScreen = [[UIScreen screens] objectAtIndex:1];
_secondWindow = [[UIWindow alloc] initWithFrame:secondScreen.bounds];
self.secondWindow.screen = secondScreen;
_externalViewController = [[YourExternalViewControllerClass alloc] init];
self.secondWindow.rootViewController = self.externalViewController;
self.secondWindow.hidden = NO;
}
In the above example the _secondWindow and _externalViewController instances are properties of the viewController setting up the device view.

Related

Xcode iOS external display mirroring

Im working at a local newspaper and I have built a simple video uploading app that we are going to use inside our organization to make it easier to upload videos to our servers.
My issues is that when I'm going to demonstrate it for +100 people i would like to use a projector using a hdmi adapter. So i bought the adapter for my iPhone and it works great if it wasn't for one thing. When i edit the clip before uploading it (the simple editing tool that is a part of the AVfoundation) it dosnt mirror the editing tools to the hdmi screen. The projector just shows the video in fullscreen. So i can't demonstrate the buttons and tools for editing. Everything else works perfectly to mirror by default. Is there some way to force it to truly mirror it instead? Has tried reading Apples official iOS database about it but only found info about when it comes to video playback.
The code for the camera and the editing:
// Hides the controls for moving & scaling pictures, or for
// trimming movies. To instead show the controls, use YES.
cameraUI.allowsEditing = YES;
cameraUI.cameraFlashMode = UIImagePickerControllerCameraFlashModeAuto;
cameraUI.videoQuality = UIImagePickerControllerQualityTypeHigh;
cameraUI.delegate = delegate;
// Show camera view controller.
[controller presentViewController:cameraUI animated:NO completion:nil ];
The best way to go is by using the apple tv, and also the recommended one
http://www.apple.com/airplay/

How to display overlay on Apple TV via AirPlay

I am developing an iOS app that displays a video, e.g., a football game, on Apple TV via AirPlay. I want to display additional information, e.g., player stats, on the big screen while the video is playing.
I am aware of the Redfin approach, where they require the user to turn on AirPlay mirroring first. Unfortunately, this is not acceptable for us. We want it to be obvious to users on how to show the video.
We are currently presenting an AirPlay Route button before displaying the video to allow the user to set it up using the following code.
self.airPlayPicker = [[MPVolumeView alloc] initWithFrame:CGRectMake(0, 0, 50, 50)];
self.airPlayPicker.showsVolumeSlider = NO;
self.airPlayPicker.showsRouteButton = YES;
[self.view addSubview:self.airPlayPicker];
The Route button will show when there is an Apple TV around, allowing the user to turn it on. We then present the video with MPMoviePlayerController.
When AirPlay is turned on and the video is playing, in code, I see only one UIScreen, but two UIWindows. But both UIWindows have the same dimensions as the iPhone. When I add a subview to either UIWindow, the subview always shows up on the iPhone.
Has anyone figured out how to present an overlay on top of the video on Apple TV? How do I even find the view object where the video is hosted?
I am aware that MPMoviePlayerController is built on top of AVPlayer. Would using AVPlayer give us better control of the UI?
As far as I know, this shouldn't be possible. When using AirPlay without mirroring, only the URL of the video is sent to the Apple TV. It is then up to the Apple TV to actually play the media.
Mirroring is the way to do it.

How do I remove the airplay from a video player for the ipad?

So I have this player that I am using to video locally. I need to be able to mirror airplay the screen to a tv but every time I set airplay to mirror the player just sends the whole video to the screen instead of just mirroring.
https://github.com/NOUSguide/NGMoviePlayer
I contacted the developers about how to disable the airplay part of it. They told me to remove the airplay layer from the player. Can someone lead me into the right direction into getting this done?
If you want to disable AirPlay, just set the allowsAirPlay property to false in your MoviePlayerController object.
You can access the mirrored screen by using this method :
UIScreen * screen = [[UIScreen screens] objectAtIndex:1];
before calling this method, ensure that the screens property has more than one object

Adding subtitles to AirPlay video using AVFoundation on iOS?

Is there any way to make subtitles show over AirPlay on iOS using av AVPlayer with anAVPlayerItem? I've currently implemented subtitles by adding labels to the view hierarchy which works fine in the app, but that obviously doesn't work with AirPlay.
So, is there any way to display subtitles over AirPlay using AVFoundation?
You mentioned that you already implemented your own CC by creating a view for CC and adding it on top of the video. It will be easier to use AirPlay mirroring. You can do this by detecting an external screen and then place the content on it.
// detecting an external screen
[[NSNotificationCenter defaultCenter] addObserver:self selector:#selector(myExternalScreenDetected:) name:UIScreenDidConnectNotification object:nil];
//
// Grab external screen then add the content
- (void)myExternalScreenDetected:(UIScreen *)externalScreen {
UIWindow *window = [[UIWindow alloc] initWithFrame:externalScreen.bounds];
// ...add content to the window...
window.screen = externalScreen;
window.hidden = NO;
}
Another option is to use native closed caption.This can be done by adding language files (WebVTT format) into the m3u8 playlist. I haven't tried this. It seems more complicated. You can take a look at the Apple's video here: https://developer.apple.com/videos/wwdc/2012/?id=512
Mirroring feature seems easier to implement CC than the native way. However the native video airplay has better performance because the AppleTV loads the playlist file (m3u8) and plays the content directly. Mirroring AirPlay has to re-compress the output and send to AppleTV.
You've probably already figured this out, but the reason your closed-captions aren't displaying when you airplay to Apple TV is probably that your AppleTV has closed captioning turned off.

Blocking HDMI output of video

For legal reasons we need to prevent users from playing the video in our app on external screen (TV, monitors), I know how to stop airplay output but we need to stop HDMI output as well, does anybody know if we can do this or perhaps we can detect HDMI output and stop the video playing altogether.
You can detect the external HDMI screens with: [[UIScreen screens] count]
Then you can get the external screen instance with: UIScreen* secondScreen = [[UIScreen screens] objectAtIndex:1];
Finally, you can create new UIWindow, ititialize it with the same screen bounds and assign the external screen to its .screen. You can add new views to this UIWindow instance.

Resources