2009-10-18 7 views

답변

2

표시 할 이미지 (또는 레이블 또는 다른 것)로 UIImageView를 만들고 MoviePlayerControllerView에 추가하기 만하면됩니다. 보기 플레이어를 추가 할 논리를 수행

moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:movie.trailerURL]; 

if ([moviePlayer respondsToSelector:@selector(loadState)]) { 

     [moviePlayer prepareToPlay]; 

     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayerLoadStateChanged:) name:MPMoviePlayerLoadStateDidChangeNotification object:moviePlayer];} 

을 다음 알림 방법 :

UIImage *loadingScreenImage = [UIImage imageNamed:@"loadingScreen.png"]; 
loadingScreen = [[UIImageView alloc] initWithImage:loadingScreenImage]; // ivar & property are declared in the interface file 
[self.view addSubview:loadingScreen]; 
[loadingScreen release]; 

그런 다음 동영상 플레이어를 인스턴스화 및 LoadState가 변경 될 때 알림을받을 등록 할 수 있습니다

- (void) moviePlayerLoadStateChanged:(NSNotification*)notification 
{ 
    // Unless state is unknown, start playback 
    switch ([moviePlayer loadState]) { 
     case MPMovieLoadStateUnknown: 
      break; 
     case MPMovieLoadStatePlayable: 
      // Remove observer 
      [[NSNotificationCenter defaultCenter] 
      removeObserver:self 
      name:MPMoviePlayerLoadStateDidChangeNotification 
      object:nil]; 

      // Set frame of movie player 
      [moviePlayer.view setFrame:CGRectMake(0, 0, 480, 320)]; 
      [moviePlayer setControlStyle:MPMovieControlStyleFullscreen]; 
      [moviePlayer setFullscreen:YES animated:YES]; 
      [self.view addSubview:[moviePlayer view]]; 

      // Play the movie 
      [moviePlayer play]; 
         ... 
} 
+0

이것은 앱의 오프닝 비디오 재생을 만드는 가장 작은 효과입니다. – Shiny

관련 문제