-->

iOS Mirroring MPMoviePlayerController to TV with T

2020-06-30 01:01发布

问题:

I have an App with video (locally stored) playback using MPMoviePlayerController

    NSString *deviceDir = [[NSUserDefaults standardUserDefaults] stringForKey:WZLDEVICEPATH];
NSString *videopath = [deviceDir stringByAppendingPathComponent:video]
NSURL *url = [NSURL fileURLWithPath:videopath];
player = [[MPMoviePlayerController alloc] initWithContentURL:url];
CGRect viewInsetRect = CGRectInset (playerframe,
                                            0.0,
                                            0.0 );
        /* Inset the movie frame in the parent view frame. */
[[player view] setFrame:viewInsetRect];
[player view].backgroundColor = [UIColor clearColor];
[player view].tag = TAG_VIDEO_PLAYER;
player.movieSourceType = MPMovieSourceTypeFile;
[player prepareToPlay];
[self.view addSubview: [player view]];

Now I need to mirror the App to an external device, the mirroring just works fine to the second screen (TV), but the TV playback is in the same resolution(width x height) as it is in the iPad, I have to make the TV playback in fullscreen. Is there any way to make sync playback in two devices at different resolution.

I have tried for the multiple window with different instance of MPMoviePlayerController but there the sync playback is getting affected. Is there some work around to overcome these issues?

回答1:

[secondScreen  setOverscanCompensation: UIScreenOverscanCompensationInsetApplicationFrame];

With the above settings videos in 16:9 resolution starts playing by filling the whole screen & 4:3 videos with black bars on top & bottom which is ok, as we know to keep the aspect ratio it need to be there.

Note I have also noticed when we use iPad Mini the older behaviour still keep on coming.