我怎么能在像路径这样的UIView中嵌入视频?

lin*_*hao 4 video path ios

在此输入图像描述

从Path App中可以看到图片,你可以看到,在表视图中,有一个视频片段,当我触摸播放按钮时,视频播放时无需更改为全屏.

看来视频嵌入在表格视图中?

这该怎么做?你举个例子吗?谢谢

jim*_*pic 8

从我的一个项目中选择,只需调整它以满足您的需求:

    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];
Run Code Online (Sandbox Code Playgroud)