MPMoviePlayerController在流式传输时自动播放 - 如何停止播放? [英] MPMoviePlayerController autoplays when streaming - how do I stop it?

查看:161
本文介绍了MPMoviePlayerController在流式传输时自动播放 - 如何停止播放?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在iPad上播放一部电影。如果我只是加载一个mp4文件,播放器不会自动启动 - 但是使用示例m3u8,它坚持自动启动。有没有人遇到过这个?我做错了什么?

I'm streaming a movie on the iPad. If I just load a mp4 file, the player doesn't autostart - but with the example m3u8, it insists on autostarting. Has anyone encountered this? Am I doing something wrong?

- (id)initWithVideo:(VideoDO*)video frame:(CGRect)rect { 
NSURL* videoURL = [NSURL     URLWithString:@"http://devimages.apple.com/iphone/samples/bipbop/bipbopall.m3u8"]; // With    this URL, player starts automatically
 self.moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:videoURL];

 moviePlayer.shouldAutoplay = NO;
 moviePlayer.controlStyle = MPMovieControlStyleEmbedded;
 moviePlayer.view.frame = rect;
 moviePlayer.view.backgroundColor = [UIColor blackColor]; 
 [moviePlayer prepareToPlay];  

 self.view = moviePlayer.view;   
 [moviePlayer stop];

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


 return self;
} 


推荐答案

在这里你可以做[moviePlayer暂停];而不是[moviePlayer stop];并删除行[moviePlayer prepareToPlay];从代码,它将工作。如果有任何问题,请告诉我。

Here you can do [moviePlayer pause]; instead of [moviePlayer stop]; and remove the line [moviePlayer prepareToPlay]; from the code and it will work. Let me know if any problem.

这篇关于MPMoviePlayerController在流式传输时自动播放 - 如何停止播放?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆