iOS将MPMoviePlayerController镜像到电视,全屏播放电视屏幕 [英] iOS Mirroring MPMoviePlayerController to TV with TV screen playback in fullscreen

查看:177
本文介绍了iOS将MPMoviePlayerController镜像到电视,全屏播放电视屏幕的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用MPMoviePlayerController播放视频(本地存储)的应用程序

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]];

现在我需要将应用程序镜像到外部设备,镜像可以正常工作到第二个屏幕(电视),但电视播放的分辨率(宽度x高度)和iPad一样,我必须全屏播放电视。有没有办法在不同分辨率的两个设备上进行同步播放。

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.

我尝试过使用不同MPMoviePlayerController实例的多窗口,但同步播放受到影响。是否有一些解决这些问题的工作?

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?

推荐答案

[secondScreen  setOverscanCompensation: UIScreenOverscanCompensationInsetApplicationFrame];

通过以上设置,16:9分辨率的视频将通过填充整个屏幕开始播放。 4:3视频,顶部带有黑条和&底部是好的,因为我们知道要保持它所需的宽高比。

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.

注意我也注意到当我们使用iPad Mini时,旧的行为仍然存在来了。

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

这篇关于iOS将MPMoviePlayerController镜像到电视,全屏播放电视屏幕的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆