iPhone:启动时播放视频不会退出
我制作了一个在我的应用程序加载时播放的视频,但是即使您按下“完成”,它在播放后也不会退出。我做错了什么?
- (void)viewDidLoad {
NSBundle *bundle=[NSBundle mainBundle];
NSString *moviePath = [bundle pathForResource:@"Video Logo Final" ofType:@"mp4"];
NSURL *movieURL=[[NSURL fileURLWithPath:moviePath] retain];
MPMoviePlayerController *theMovie = [[MPMoviePlayerController alloc] initWithContentURL:movieURL];
theMovie.scalingMode = MPMovieScalingModeAspectFill;
theMovie.view.frame = CGRectMake(0.0, 0.0, 320.0, 480.0);
[self.view addSubview:theMovie.view];
[theMovie play];
[super viewDidLoad]; }
另外,我尝试将相同的代码放入“application didFinishLaunchingWithOptions”中,但在“[self.view addSubview:theMovie.view];”处收到警告 有什么想法吗?
ps 正如您可能猜到的那样,我对编程非常陌生,任何帮助将不胜感激......
i made a video playing when my app loads however it doen't quit after playing even if you prees "Done". What am i doing wrong?
- (void)viewDidLoad {
NSBundle *bundle=[NSBundle mainBundle];
NSString *moviePath = [bundle pathForResource:@"Video Logo Final" ofType:@"mp4"];
NSURL *movieURL=[[NSURL fileURLWithPath:moviePath] retain];
MPMoviePlayerController *theMovie = [[MPMoviePlayerController alloc] initWithContentURL:movieURL];
theMovie.scalingMode = MPMovieScalingModeAspectFill;
theMovie.view.frame = CGRectMake(0.0, 0.0, 320.0, 480.0);
[self.view addSubview:theMovie.view];
[theMovie play];
[super viewDidLoad]; }
Also, i made a try to put the same code in "application didFinishLaunchingWithOptions" but i get a warning at "[self.view addSubview:theMovie.view];"
Ay ideas about that?
p.s. As you probably guessed i am very new to programming, any help would be really appreciated...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
基本上,您需要注册才能收到通知。
我这样做的方法是:
更改参数以适应您的应用程序。
这是 MPMoviePlayerPlaybackDidFinishNotification 的文档。
另外,如果播放后没有“退出”(即使点击“完成”按钮),听起来您需要从最初添加到的视图中删除
theMovie
MPMoviePlayerController 和关联的视图。Basically you need to register for a notification.
The way I do it is:
Change the parameters to fit however it should in your app.
Here's the documentation for the MPMoviePlayerPlaybackDidFinishNotification.
Also, if it's not "quitting" after playing (even when hitting the "Done" button), it sounds like you need to remove the
theMovie
MPMoviePlayerController and associated view from the view you originally added it to.