我想在我的应用程序中播放一个具有透明背景的视频。它有一个人在透明背景上四处走动。唯一的问题是 MPMovieePlayer 似乎有黑色背景。我怎样才能使它透明?
这是我试过的代码:
-(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];
似乎正在移除播放器的框架,而不是实际的背景。谢谢你的帮助。