4

在此处输入图像描述

图片是从 Path App 截取的,你可以看到,在表格视图中,有一个视频剪辑,当我点击播放按钮时,视频播放而不会变成全屏。

似乎视频嵌入在表格视图中?

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

4

2 回答 2

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];
于 2012-06-06T08:12:57.903 回答
3

用于视频播放HTML5UIWebView因为初始是海报图像,点击视频根据您的要求开始。

请参阅链接以在 webView 中播放视频。

希望它有帮助!

于 2012-06-06T09:00:05.233 回答