如何在 MPMoviePlayerController 中停止视频下载
我有一个要求,我必须播放远程位置可用的视频文件。
我将 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
将初始播放时间设置为 -1 应该可以解决您的问题。
Setting initial playbacktime to -1 should solve your problem.
您可以注册 MPMoviePlayerController 在完成时发出的 NSNotification。这是一个例子:
一个好的地方是把它放在主 ViewController 类的“viewDidLoad”中。
然后在你的方法“movieFinishedCallback:”(它获取一个作为参数传入的 NSNotification 对象,如果你愿意的话,你可以使用它来查找有关所发生的完成类型的更多详细信息),你只需关闭 movieplayercontroller
You to register for an NSNotification that the MPMoviePlayerController sends out when it finishes. Here is an example:
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