图片是从 Path App 截取的,你可以看到,在表格 View 中,有一个视频剪辑,当我点击播放按钮时,视频播放而没有切换到全屏。
视频似乎嵌入在表格 View 中?
如何做到这一点?你能举个例子吗?谢谢
最佳答案
取 self 的一个项目,只需根据您的需要进行调整即可:
NSURL *movieUrl = [NSURL fileURLWithPath:moviePath];
MPMoviePlayerController *player = [[MPMoviePlayerController alloc] initWithContentURL:movieUrl];
player.view.frame = CGRectMake(0, 0, 690, 370);
// Here is where you set the control Style like fullscreen or embedded
player.controlStyle = MPMovieControlStyleDefault;
//player.controlStyle = MPMovieControlStyleEmbedded;
//player.controlStyle = MPMovieControlStyleDefault;
//player.controlStyle = MPMovieControlStyleFullscreen;
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(movieFinished) name:MPMoviePlayerPlaybackDidFinishNotification object:player];
UIView *movieBox = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 600, 400)];
[movieBox setBackgroundColor:[UIColor blackColor]];
[movieBox addSubview:player.view];
[self.view addSubview:movieBox];
player.scalingMode = MPMovieScalingModeAspectFit;
player.contentURL = movieUrl;
[player play];
关于ios - 我怎么能在像 Path 这样的 UIView 中嵌入视频?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10910309/