ios - 我怎么能在像 Path 这样的 UIView 中嵌入视频?

标签 ios video path

enter image description here

图片是从 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/

相关文章:

video - 如何在没有 ffmpeg 的情况下合并两个文件

php - 无法播放从android上传到php服务器的视频

ios - 通过 CAGradientLayer 在 IOS 的 UIImageView 中添加渐变层

ios - 一次使用 SQL for iOS 应用程序和网页

java - 有没有办法将 JavaFX 动画导出到图像帧?

javascript - d3 行生成器返回 null 而不是路径数据字符串

c++ - 为什么L在dll路径之前?

java - 在 Netbeans 中读取图像

iphone - 如何在打开应用程序时将第一个 viewController 屏幕设置为默认打开屏幕

iphone - 线程间 'communication' 问题