如何从我的应用程序启动 QuickTime?

发布于 2024-09-05 00:33:19 字数 1387 浏览 6 评论 0原文

我正在尝试从网络加载视频,但无法使其显示在 QuickTime 中。我只能听到音频。我希望它能够启动 QuickTime。

- (void)loadView {
    NSURL *movieURL = [NSURL URLWithString:@"http://movies.apple.com/media/us/mac/getamac/2009/apple-mvp-biohazard_suit-us-20090419_480x272.mov"];


    if (movieURL != nil) {
        moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:movieURL];

        moviePlayer.initialPlaybackTime = -1.0;

        // Register to receive a notification when the movie has finished playing. 
        [[NSNotificationCenter defaultCenter] addObserver:self
                                                 selector:@selector(moviePlayBackDidFinish:) 
                                                     name:MPMoviePlayerScalingModeDidChangeNotification 
                                                   object:moviePlayer];

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

        moviePlayer.scalingMode = MPMovieScalingModeAspectFit; 
        moviePlayer.movieControlMode = MPMovieControlModeDefault;
        moviePlayer.backgroundColor = [UIColor blackColor];

        [moviePlayer play];
    }
}

I am trying to load a video from the web, but am having trouble getting it to appear in QuickTime. I can only hear the audio. I would like it to launch QuickTime.

- (void)loadView {
    NSURL *movieURL = [NSURL URLWithString:@"http://movies.apple.com/media/us/mac/getamac/2009/apple-mvp-biohazard_suit-us-20090419_480x272.mov"];


    if (movieURL != nil) {
        moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:movieURL];

        moviePlayer.initialPlaybackTime = -1.0;

        // Register to receive a notification when the movie has finished playing. 
        [[NSNotificationCenter defaultCenter] addObserver:self
                                                 selector:@selector(moviePlayBackDidFinish:) 
                                                     name:MPMoviePlayerScalingModeDidChangeNotification 
                                                   object:moviePlayer];

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

        moviePlayer.scalingMode = MPMovieScalingModeAspectFit; 
        moviePlayer.movieControlMode = MPMovieControlModeDefault;
        moviePlayer.backgroundColor = [UIColor blackColor];

        [moviePlayer play];
    }
}

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

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

发布评论

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

评论(3

过期以后 2024-09-12 00:33:19

我改用视图控制器:

moviePlayerViewController = [[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL URLWithString:mySTVideo.video_url]];

[self presentModalViewController:moviePlayerViewController animated:YES];

[moviePlayerViewController release];

i used the view controller instead:

moviePlayerViewController = [[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL URLWithString:mySTVideo.video_url]];

[self presentModalViewController:moviePlayerViewController animated:YES];

[moviePlayerViewController release];
回忆那么伤 2024-09-12 00:33:19

您在设备上尝试过吗?我听说当设备正常时模拟器有时会出现此问题。

Have you tried it on the device? I've heard of the simulator sometimes having this problem when the device is OK.

两个我 2024-09-12 00:33:19

让它出现在 QuickTime 中的另一个解决方案是:

NSString * urlStr = @"http://movies.apple.com/media/us/mac/getamac/2009/apple-mvp-biohazard_suit-us-20090419_480x272.mov";
NSString * htmlStr = [[@"<html><body><video preload=\"auto\" autoplay=\"true\"><source src=\"" stringByAppendingString:urlStr] stringByAppendingString:@"\"></video></body></html>"];
UIWebView * wv = [[UIWebView alloc] init];
wv.frame = self.view.frame;
[self.view addSubview:wv];
wv.hidden = true;
wv.mediaPlaybackRequiresUserAction = false;
[wv loadHTMLString:htmlStr baseURL:nil];

但是当 QuickTime 播放器关闭时,您必须手动从超级视图中删除 Web 视图。

another solution to getting it to appear in QuickTime is:

NSString * urlStr = @"http://movies.apple.com/media/us/mac/getamac/2009/apple-mvp-biohazard_suit-us-20090419_480x272.mov";
NSString * htmlStr = [[@"<html><body><video preload=\"auto\" autoplay=\"true\"><source src=\"" stringByAppendingString:urlStr] stringByAppendingString:@"\"></video></body></html>"];
UIWebView * wv = [[UIWebView alloc] init];
wv.frame = self.view.frame;
[self.view addSubview:wv];
wv.hidden = true;
wv.mediaPlaybackRequiresUserAction = false;
[wv loadHTMLString:htmlStr baseURL:nil];

but you have to remove the webview from superview manually when quicktime player is closed.

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