让视频在模拟器中播放

发布于 2024-09-26 13:02:42 字数 648 浏览 3 评论 0原文

因此,我的应用程序中弹出了一个警报视图,单击视图按钮后,应该播放视频,但模拟器中没有任何反应。我不想在设备上测试它,直到它在模拟器中运行为止。据我所知,这是下面的代码,它应该可以工作。它到达 Log 语句并输出到控制台,但视频不播放。有什么想法吗?

-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex: (NSInteger)buttonIndex{
    if (buttonIndex == 1) {
        NSURL *url = [NSURL URLWithString:@"http://srowley.co.uk/endyVid.mp4"];
        MPMoviePlayerController *player = [[[MPMoviePlayerController alloc] initWithContentURL:url] autorelease];

        //---play movie---
        [player setFullscreen:YES];
        [self.view addSubview:[player view]];
        NSLog(@"Player Should play!");
        [player play]; 
    }
}

So I have an alert view pop up in my application and on clicking a view button a video is supposed to play but nothing happens in the simulator. I don't want to test this on a device until I get it working in the simulator. This is the code below as far as I can tell it should work. It reaches the Log statement and outputs to the console but the video does not play. Any ideas?

-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex: (NSInteger)buttonIndex{
    if (buttonIndex == 1) {
        NSURL *url = [NSURL URLWithString:@"http://srowley.co.uk/endyVid.mp4"];
        MPMoviePlayerController *player = [[[MPMoviePlayerController alloc] initWithContentURL:url] autorelease];

        //---play movie---
        [player setFullscreen:YES];
        [self.view addSubview:[player view]];
        NSLog(@"Player Should play!");
        [player play]; 
    }
}

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

姜生凉生 2024-10-03 13:02:42

您需要在玩家视图上设置框架。

    [[player view] setFrame: [self.view bounds]];

You need to set the frame on player's view.

    [[player view] setFrame: [self.view bounds]];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文