2

I have looked several links and read the Apple Documentation but I don't get any step-wise instructions to mirror the content of app on an external device. All they explain is how to display a new window for an external screen if recognized.

In my app, I just need to display the current screen being shown in the app on an airplay enabled device. There is a airplay button, clicking on which will check for available external screens and display the content present on the device on that screen.

Filburt
  • 17,626
  • 12
  • 64
  • 115
AJS
  • 1,403
  • 12
  • 17

1 Answers1

1

Well the reason is simple. AirPlay mirroring is enabled by the user from the settings as @Meera mentioned below. The idea to use in code app is to either display selective things (audio/video) on the TV via AirPlay or to use it as a second Window, where the user does see other things. However if you want you can simply send the whole view to the external screen using this code:

// Check for external screen and if found send output there
if ([[UIScreen screens] count] > 1) {
    UIScreen *externalScreen = [[UIScreen screens] objectAtIndex:1];
    NSArray *screenModes = externalScreen.availableModes;
    //set max resolution
    externalScreen.currentMode = [screenModes lastObject];
    self.window.screen = externalScreen;
}
Lefteris
  • 14,550
  • 2
  • 56
  • 95
  • Thanks for answering.This is similar to what I found by digging out the Apple's documentation. What I need to do is from my app I have to give an airplay option. And clicking on it should mirror the content. Is there a way to do so from app itself. Is it necessary to swipe up on device screen and enable airplay from control panel only? – AJS Mar 13 '14 at 05:27
  • If I need to show different content on TV along with the audio being played on the app, what stuff will I need to do? – AJS Mar 19 '14 at 05:00
  • Is there a way to get the list of airplay devices available around and display the list in an app? The above lists the available screens. I need to show a list like in Youtube app on iOS devices. – AJS Apr 08 '14 at 05:33