开发者

How to enable the video output on your iPad app?

开发者 https://www.devze.com 2022-12-26 00:29 出处:网络
Just found out that the video output of the iPad is not a system level functionality, but that it needs to be explicitly build in into each app.

Just found out that the video output of the iPad is not a system level functionality, but that it needs to be explicitly build in into each app. Is there somebody who has any experience with this, who could point me to sample code? Secondary question w开发者_开发问答ould be: why wouldn't Apple make this a system feature. Is it a hardware issue, that I should be aware of when building this into my app?


External Display Support

An iPad can be connected to an external display through a set of supported cables. When connected, the associated screen can be used by the application to display content. Information about the screen, including its supported resolutions, is accessible through the interfaces of the UIKit framework. You also use that framework to associate your application’s windows with one screen or another.

  • The UIScreen class provides support for retrieving screen objects for all available screens (including the device’s main screen). Each screen object contains information about the properties of the screen itself, including the dimensions that correctly take into account the size and pixel aspect ratio of the screen.

  • The UIScreenMode class provides information about one particular size and pixel aspect ratio setting of a screen.

  • Windows (represented by the UIWindow class) can now be assigned to a specific screen.


Sorry, I don't seem to have the necessary standing to comment on other posts. So, here's a bit of code that might be useful to explore new External Display Support:

    NSUInteger numScreens = [[UIScreen screens] count];
DLog(@"[[UIScreen screens] count] = %d", numScreens);
NSUInteger j = 0;
for (UIScreen *screen in [UIScreen screens])
    {
    DLog(@" screen %d", j++);
    NSArray *modes = [screen availableModes];
    for (int i = 0; i < [modes count]; ++i)
        {
        UIScreenMode *mode = [modes objectAtIndex:i];
        DLog(@"  modes[%d] : size = (%f, %f) ; aspect ration = %f", i, mode.size.width, mode.size.height, mode.pixelAspectRatio);
        }
    }

Note that you still need some sort of video cable. I have tested this with Apple's Component AV Cable. Although ungainly, this is nice for debugging because it has USB and 30-pin connector, so you can be connected to iPhone/iPad and run your app in debugger.

The problem is that you will still need to do some work to mirror parts of your display to external screen, while keeping controls on iPhone/iPad. You might want to look at this link text for inspiration.


The TVOutManager class handles the entire process.

Here is the info: http://www.touchcentric.com/blog/archives/123

And github: https://github.com/robterrell/TVOutManager


This discussion is now less relevant, since in current versions of iOS, display mirroring is now supported at the system level.

0

精彩评论

暂无评论...
验证码 换一张
取 消