iOS5 上使用 MPMoviePlayerController 的 Vimeo 无法加载视频

发布于 2025-01-05 10:44:55 字数 1420 浏览 0 评论 0原文

以下代码在 Web 视图中加载 Vimeo 视频效果很好,但用户必须单击播放 按钮开始

    VidViewController *webScrollView = 
    [[VidViewController alloc] initWithNibName:@"VidViewController" bundle:nil];

    NSURL *url = [NSURL URLWithString:@"http://player.vimeo.com/video/36120576"];
    NSURLRequest *request = [NSURLRequest requestWithURL:url];
    webScrollView.request = request;
    [self.navigationController pushViewController:webScrollView animated:YES];
    [webScrollView release];

我想让 MPMoviePlayerController 工作,但无法加载视频。

- (void)viewDidLoad
{
    [super viewDidLoad];
    NSURL *audioURL = [NSURL URLWithString:@"http://player.vimeo.com/video/36120576"];
    MPMoviePlayerController *player = [[MPMoviePlayerController alloc]
    initWithContentURL:audioURL];

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


        [player play];    

}

- (void) movieFinishedCallback:(NSNotification*) aNotification {
    MPMoviePlayerController *player = [aNotification object];
    [[NSNotificationCenter defaultCenter]
    removeObserver:self
    name:MPMoviePlayerPlaybackDidFinishNotification
    object:player];    
    [player autorelease];    
}

Developer.apple 上没有太多支持

The following code loads a Vimeo vide just fine in a webview, but the user has to click the play
button to start

    VidViewController *webScrollView = 
    [[VidViewController alloc] initWithNibName:@"VidViewController" bundle:nil];

    NSURL *url = [NSURL URLWithString:@"http://player.vimeo.com/video/36120576"];
    NSURLRequest *request = [NSURLRequest requestWithURL:url];
    webScrollView.request = request;
    [self.navigationController pushViewController:webScrollView animated:YES];
    [webScrollView release];

I would like to get MPMoviePlayerController to work, but can't get the video to load.

- (void)viewDidLoad
{
    [super viewDidLoad];
    NSURL *audioURL = [NSURL URLWithString:@"http://player.vimeo.com/video/36120576"];
    MPMoviePlayerController *player = [[MPMoviePlayerController alloc]
    initWithContentURL:audioURL];

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


        [player play];    

}

- (void) movieFinishedCallback:(NSNotification*) aNotification {
    MPMoviePlayerController *player = [aNotification object];
    [[NSNotificationCenter defaultCenter]
    removeObserver:self
    name:MPMoviePlayerPlaybackDidFinishNotification
    object:player];    
    [player autorelease];    
}

There isn't much support on developer.apple

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文