1
我在我的項目中有視頻。我用MPMoviePlayerController播放它,但應用程序需要一段時間才能加載。現在我想吃另一個功能。當視頻開始播放時。如何知道何時視頻已經加載並開始播放以及如何調用其他功能。當它播放?如何知道視頻播放時間?
請問你能指導我嗎?
這裏是一些簡單的代碼
-(IBAction)testVideoLongPress:(id)sender
{
NSString *moviePath = [[NSBundle mainBundle] pathForResource:@"video1" ofType:@"MOV"];
movie = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL fileURLWithPath:moviePath]];
movie.view.backgroundColor = [UIColor blackColor];
movie.controlStyle = MPMovieControlStyleDefault;
movie.shouldAutoplay = YES;
movie.view.frame = CGRectMake(0, 50, 720, 1280);
[self.view addSubview:movie.view];
[movie play];
}
-(void)wannalunchthismethod
{
....
}
非常感謝。我會盡力告訴你:) – crazyoxygen 2012-03-23 05:13:13
我明白了,但我問了一個問題。 ([movieStatusState] == MPMovieLoadStatePlayable){ NSLog(@「MPMovieLoadStatePlayable」); (@「MPMovieLoadStatePlaythroughOK」);其他if([movie loadState] == MPMovieLoadStatePlaythroughOK) { } } 否則if([movie loadState] == MPMovieLoadStateStalled) { NSLog(@「MPMovieLoadStateStalled」); } else if([movie loadState] == MPMovieLoadStateUnknown) NSLog(@「MPMovieLoadStateUnknown」); } 什麼時候所有的NSLog都會顯示。我不明白Stateplayable,Playthroughok和停滯。 – crazyoxygen 2012-03-23 08:28:47
@crazyoxygen如果你看看[蘋果文檔的MPMoviePlayerController(https://developer.apple.com/library/ios/#documentation/MediaPlayer/Reference/MPMoviePlayerController_Class/Reference/Reference.html)並搜索'MPMovieLoadStatePlaythroughOK ',你可能會看到這些不同的國家是什麼意思。 – 2012-03-23 18:01:01