2013-05-05 4 views
0

투명한 배경을 가진 비디오를 내 앱 안에서 재생하고 싶습니다. 그것에는 투명 배경 위에서 움직이는 남자가 있습니다. 유일한 문제는 MPMovieePlayer가 검은 색 배경을 가진 것처럼 보입니다. 어떻게 투명하게 만들 수 있습니까?투명 배경을 가진 MPMoviePlayerViewController 비디오

이 I 시도한 코드 :

-(void)playMovie 
{ 
     NSString *resourcePath = [[NSBundle mainBundle] pathForResource:@"syncink movie" ofType:@"m4v"]; 
     NSLog(@"%@",resourcePath); 
     NSURL *url = [NSURL fileURLWithPath:resourcePath]; 
     NSLog(@"%@",url); 

     MPMoviePlayerViewController *moviePlayer; 

     moviePlayer = [[MPMoviePlayerViewController alloc] initWithContentURL:url]; 

     moviePlayer.moviePlayer.shouldAutoplay=YES; 
     moviePlayer.moviePlayer.controlStyle = MPMovieControlStyleNone; 
     [moviePlayer.moviePlayer setFullscreen:NO animated:YES]; 
     [self.view addSubview:moviePlayer.view]; 

     moviePlayer.view.frame = CGRectMake(200, 600, 400, 300); 

     [moviePlayer.moviePlayer play]; 

     moviePlayer.view.backgroundColor = [UIColor clearColor]; 

     for(UIView *aSubView in moviePlayer.view.subviews) 
     { 
      aSubView.backgroundColor = [UIColor clearColor]; 
     } 
} 

하지만

aSubView.backgroundColor = [UIColor clearColor];

실제 배경이 아닌 플레이어의 프레임을 제거하는 것처럼 보입니다. 어떤 도움을 주셔서 감사합니다.

답변

0

여기서 MPMoviePlayerViewController 대신 MPMoviePlayerController을 사용해야합니다. 후자는 (일반적으로 모달 방식으로) 제시된 뷰 컨트롤러입니다.

이렇게하면 moviePlayer.view를 하위보기로 계층 구조에 추가 할 때 동영상 플레이어가 포함 된보기 (보는 평면 검은 화면)가 아닌 동영상 플레이어보기 자체가 추가됩니다).

또한 MPMoviePlayerController을 사용하여 모든 곳의 코드에서 moviePlayer.moviePlayer을 단순화하여 moviePlayer으로 만들 수 있습니다.

관련 문제