iPhone应用程序:仅在小视图中播放视频

时间:2012-06-13 09:45:00

标签: iphone ios5 video uiwebview mpmovieplayercontroller

在我的iPhone App中,我想以小视角播放视频。

视频应自动开始播放,并且应隐藏播放暂停和全屏按钮。

enter image description here

我怎样才能做到这一点?

2 个答案:

答案 0 :(得分:0)

您要做的是手动设置MPMoviePlayerController视图的框架,并将控件样式设置为MPMovieControlStyleNone。就像下面这样......

....
MPMoviePlayerController *player = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL fileURLWithPath:url]];
[player setControlStyle:MPMovieControlStyleNone];

//this is where you create your `embedded` view size
player.view.frame = CGRectMake(0, 0, 200, 300);

[self.view addSubview:player.view];
....

答案 1 :(得分:0)

    MPMoviePlayerController *player = [[MPMoviePlayerController alloc] init];
[player prepareToPlay];
player.shouldAutoplay = NO;
player.allowsAirPlay = YES;
player.scalingMode = MPMovieScalingModeAspectFit;
[player.view setFrame:CGRectMake(0,0,300,320)];
[viewPlayer addSubview:player.view];

    self.moviePlayer = player;//declare MPMoviePlayerController class object globaly for play and push the vedio if you want to add this functionality
希望,这有助于你.... :)