首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >iOS4 MPMoviePlayerController嵌入

iOS4 MPMoviePlayerController嵌入
EN

Stack Overflow用户
提问于 2011-03-18 13:09:38
回答 1查看 4.1K关注 0票数 3

我目前正在使用MPMoviePlayerController在IPhone中播放一个视频,现在我希望在视图的一个小区域(而不是全屏)播放这个视频。我认为有一个框架的方式来做它,但我找不到必要的教程在某处。你遇到过什么吗?那太好了。

已更新

我已经达到了这一点,但它仍然没有显示球员在屏幕上发挥。

代码语言:javascript
复制
-(IBAction)startVideo {
    //start video here
    NSURL *path = [[NSURL alloc] initWithString:[self localVideoPath:NO]];

    // Create custom movie player   
    MPMoviePlayerController *moviePlayer = [[[MPMoviePlayerController alloc] initWithContentURL:path] autorelease];

    [moviePlayer setScalingMode:MPMovieScalingModeAspectFill];
    [moviePlayer setControlStyle:MPMovieControlStyleNone];
    [moviePlayer setFullscreen:FALSE];

    // May help to reduce latency
    [moviePlayer prepareToPlay];

    [[NSNotificationCenter defaultCenter]
        addObserver:self
        selector:@selector(onMSAASDone:)
        name:MPMoviePlayerPlaybackDidFinishNotification
        object:moviePlayer];


    //---play partial screen---
    //moviePlayer.view.frame = CGRectMake(0, 0, 200, 300);
    moviePlayer.view.frame = image.frame;
    //[[moviePlayer view] setFrame: [image bounds]];

    [image removeFromSuperview];

    [self.view addSubview:moviePlayer.view];

    // Show the movie player as modal
    //[self presentModalViewController:moviePlayer animated:YES];

    // Prep and play the movie
    [moviePlayer play]; 
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2011-03-18 13:20:49

这是“窗口”密码..。

代码语言:javascript
复制
MPMoviePlayerController *player =
[[MPMoviePlayerController alloc]
 initWithContentURL:[NSURL fileURLWithPath:url]];

[player setControlStyle:MPMovieControlStyleNone];

[[NSNotificationCenter defaultCenter]
 addObserver:self
 selector:@selector(movieFinishedCallback:)
 name:MPMoviePlayerPlaybackDidFinishNotification
 object:player];
[player setScalingMode:MPMovieScalingModeAspectFill];
[player setFullscreen:FALSE];

//---play partial screen---
player.view.frame = CGRectMake(0, 0, 200, 300);
[self.view addSubview:player.view];
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/5352413

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档