簡體   English   中英

視頻無法播放iOS應用

[英]Video not playing ios app

我試圖在單擊UITabBar項時播放視頻。 我遵循了本教程: http : //www.techotopia.com/index.php/Video_Playback_from_within_an_iOS_5_iPhone_Application

每當我單擊UITabBar項時,它僅顯示普通視圖,而不添加電影視圖。 這是我的代碼:

- (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];
}

我也遇到以下錯誤:

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)

有人可以幫我嗎? 謝謝!

您好,嘗試添加其中一些內容。

1)確保在運行階段在構建階段將電影添加到副本包資源中。

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];

讓我知道你怎么出來的。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM