我使用MPMediaPlayerController,我需要永久隐藏UI的元素。 但是我可以在玩家开始播放视频时看到它,2秒后它会隐藏。 我用:
setControlStyle:MPMovieControlModeHidden
。
player = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL URLWithString:@"http://catholictvhd-lh.akamaihd.net/i/ctvhd_1@88148/index_3_av-p.m3u8"]];
[player.view setFrame:self.view.bounds];
player.view.backgroundColor = [UIColor blueColor];
player.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
CGSize maxSize;
if([[UIScreen screens]count] > 1) {
[self logIt:@"External screen is available"];
newwindow = [[UIWindow alloc] init];
// There is a external display.
UIScreenMode *maxScreenMode;
for(int i = 0; i < [[[[UIScreen screens] objectAtIndex:1] availableModes]count]; i++)
{
UIScreenMode *current = [[[[UIScreen screens]objectAtIndex:1]availableModes]objectAtIndex:i];
if(current.size.width > maxSize.width)
{
maxSize = current.size;
maxScreenMode = current;
}
}
UIScreen *external = [[UIScreen screens] objectAtIndex:1];
external.currentMode = maxScreenMode;
[self logIt:[NSString stringWithFormat:@"%@",maxScreenMode]];
newwindow.screen = external;
// setting external display size.
CGPoint point = CGPointMake(0.0f, 0.0f);
//CGSize size = CGSizeMake(1024.0f, 768.0f);
CGSize size = maxSize;
CGRect frame = player.view.frame;
frame.origin = point;
frame.size.width = size.width;
frame.size.height = size.height;
[player.view setFrame:frame];
[player setControlStyle:MPMovieControlModeHidden];
[player setFullscreen:YES animated:YES];
player.shouldAutoplay = YES;
[player prepareToPlay];
[player play];
答案 0 :(得分:1)
player.moviePlayer.controlStyle = MPMovieControlStyleNone; // to hide controls
在播放视频之前,您必须将子视图添加为MPMoviePlayerController
播放前添加此行
[self.view addSubview:player.view];