如何在 MPMoviePlayerController 中停止视频下载

发布于 2024-08-23 13:40:42 字数 756 浏览 13 评论 0原文

我有一个要求,我必须播放远程位置可用的视频文件。

我将 URL 传递给 MPMoviePlayerController 实例并调用方法 play。

现在,电影正在下载。在电影完全加载并返回根视图之前,我单击了“完成”按钮。

MPMoviePlayerPlaybackDidFinishNotification 通知已被调用。我已经停止了视频并释放了播放器。这是代码

- (void)movieDidFinish:(NSNotification *)aNotifciation
{

    [self.moviePlayer stop];

    [self removeActivityIndicatorView];

    [self.tableView reloadData];

    [[NSNotificationCenter defaultCenter] removeObserver:self
                                                    name:MPMoviePlayerPlaybackDidFinishNotification
                                                  object:nil];

    [moviePlayer release];

    moviePlayer = nil;

}

但是,视频仍然在后台加载,并且我也能够听到音频。

这绝不能发生。

谁能给出这个问题的解决方案吗?

I have a requirement where I have to play a video file which is available in remote location.

I am passing the URL to MPMoviePlayerController instance and called the method play.

Now, the movie is downloading. I have clicked on the "Done" button before the movie loads completely and came back to the rootview.

MPMoviePlayerPlaybackDidFinishNotification notification got called. I have stopped the video and released the player. Here is the code

- (void)movieDidFinish:(NSNotification *)aNotifciation
{

    [self.moviePlayer stop];

    [self removeActivityIndicatorView];

    [self.tableView reloadData];

    [[NSNotificationCenter defaultCenter] removeObserver:self
                                                    name:MPMoviePlayerPlaybackDidFinishNotification
                                                  object:nil];

    [moviePlayer release];

    moviePlayer = nil;

}

But, still the video is loading in the background and iam able to hear the audio also.

This must not happen.

Can anyone give the solution for this?

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

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

发布评论

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

评论(2

梦中楼上月下 2024-08-30 13:40:43
[movieplayer stop];
movieplayer.initialPlaybackTime = -1.0;
[movieplayer release]; 

将初始播放时间设置为 -1 应该可以解决您的问题。

[movieplayer stop];
movieplayer.initialPlaybackTime = -1.0;
[movieplayer release]; 

Setting initial playbacktime to -1 should solve your problem.

太阳男子 2024-08-30 13:40:43

您可以注册 MPMoviePlayerController 在完成时发出的 NSNotification。这是一个例子:

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

一个好的地方是把它放在主 ViewController 类的“viewDidLoad”中。

然后在你的方法“movieFinishedCallback:”(它获取一个作为参数传入的 NSNotification 对象,如果你愿意的话,你可以使用它来查找有关所发生的完成类型的更多详细信息),你只需关闭 movieplayercontroller

You to register for an NSNotification that the MPMoviePlayerController sends out when it finishes. Here is an example:

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

A good place to put that is inside "viewDidLoad" of your main ViewController class.

Then inside your method "movieFinishedCallback:" (which gets an NSNotification object passed in as an argument, which you can use to find our more detail about the kind of finishing that happened if you like) you simply dismiss the movieplayercontroller

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