简体   繁体   English

视频无法播放iOS应用

[英]Video not playing ios app

I am trying to get a video to play when clicking on a UITabBar item. 我试图在单击UITabBar项时播放视频。 I followed this tutorial: http://www.techotopia.com/index.php/Video_Playback_from_within_an_iOS_5_iPhone_Application 我遵循了本教程: http : //www.techotopia.com/index.php/Video_Playback_from_within_an_iOS_5_iPhone_Application

Whenever I click the UITabBar item, it just shows the normal view, it doesn't add a movie view. 每当我单击UITabBar项时,它仅显示普通视图,而不添加电影视图。 Here is my code: 这是我的代码:

- (void)viewDidLoad {
NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle]
                                     pathForResource:@"video" ofType:@"m4v"]];
MPMoviePlayerController *moviePlayer =  [[MPMoviePlayerController alloc]
                initWithContentURL:url];

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

moviePlayer.controlStyle = MPMovieControlStyleDefault;
moviePlayer.shouldAutoplay = YES;
[self.view addSubview:moviePlayer.view];
[moviePlayer setFullscreen:YES animated:YES];
}

I'm also getting the following errors: 我也遇到以下错误:

2013-01-26 15:21:08.243 Smart Mower[61339:c07] [MPAVController] Autoplay: Disabling        autoplay for pause
2013-01-26 15:21:08.244 Smart Mower[61339:c07] [MPAVController] Autoplay: Disabling autoplay
2013-01-26 15:21:08.260 Smart Mower[61339:c07] [MPAVController] Autoplay: Skipping   autoplay, disabled (for current item: 1, on player: 0)

Can someone help me out? 有人可以帮我吗? Thanks! 谢谢!

Hello try adding a few of these things. 您好,尝试添加其中一些内容。

1) Make sure your movie is being added during run time in your copy bundle resources under build phases. 1)确保在运行阶段在构建阶段将电影添加到副本包资源中。

2) Try adding the code to for your declaration like this: 2)尝试将代码添加到声明中,如下所示:

            NSString *path = [[NSBundle mainBundle] pathForResource:@"movie" ofType:@"mp4"];
            NSURL *url = [NSURL fileURLWithPath:path];
            moviePlayer = [[MPMoviePlayerViewController alloc] initWithContentURL:url];
            moviePlayer.view.frame = self.view.frame;
            moviePlayer.moviePlayer.shouldAutoplay=YES;
            moviePlayer.moviePlayer.controlStyle = MPMovieControlStyleNone;
           [moviePlayer.moviePlayer setFullscreen:YES animated:YES];
           [self.view addSubview:moviePlayer.view];
           [[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(movieFinishedCallback:)
                                           name:MPMoviePlayerPlaybackDidFinishNotification
                                           object:moviePlayer.moviePlayer];

            [moviePlayer.moviePlayer play];

Let me know how you come out. 让我知道你怎么出来的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM