1

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

enter image description here

rmaddy
  • 314,917
  • 42
  • 532
  • 579
Khant Thu Linn
  • 5,905
  • 7
  • 52
  • 120

2 Answers2

2

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.

Fogmeister
  • 76,236
  • 42
  • 207
  • 306
  • Can you please explain more for screen count? Also, when I do mirroring, I can also replace my uiview on my monitor with custom uiview so that iPad and external monitor have different view. I don't understand well. – Khant Thu Linn Jan 14 '14 at 12:19
  • Mirroring is exactly how it sounds. Each screen is the same. Like a mirror shows the same things. If you want different on each screen then don't use mirroring. – Fogmeister Jan 14 '14 at 13:19
2

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.

Community
  • 1
  • 1
T. Benjamin Larsen
  • 6,373
  • 4
  • 22
  • 32