我有一个应用程序,我点击按钮播放电影。我的电影很透明。当我点击按钮时,我的电影正常播放,但问题是它的背景颜色保持白色。我希望电影的背景颜色是透明的。这是我播放电影的代码。
-(IBAction)ClickFunny:(id)sender
{
NSString *url = [[NSBundle mainBundle]
pathForResource:@"Moviename"
ofType:@"mov"];
MPMoviePlayerController *playerController =
[[MPMoviePlayerController alloc]
initWithContentURL:[NSURL fileURLWithPath:url]];
playerController.controlStyle =MPMovieControlStyleNone;
playerController.scalingMode = MPMovieScalingModeAspectFill;
playerController.fullscreen = YES;
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(movieFinishedCallback:) name:MPMoviePlayerPlaybackDidFinishNotification object:playerController];
playerController.view.frame = CGRectMake(84, 250, 150, 10);
[self.view addSubview:playerController.view];
[playerController play];
}
- (void) movieFinishedCallback:(NSNotification*) aNotification {
MPMoviePlayerController *player = [aNotification object];
[[NSNotificationCenter defaultCenter]
removeObserver:self
name:MPMoviePlayerPlaybackDidFinishNotification
object:player];
[player stop];
[player.view removeFromSuperview];
[player autorelease];
}
答案 0 :(得分:0)
您是否尝试过设置PlayerController的背景颜色?
playerController.view.backgroundColor = [UIColor clearColor];
答案 1 :(得分:0)
您无法使用内置iOS逻辑,因为iOS电影播放仅支持24BPP像素。有关使用带Alpha通道的视频的真实解决方案,请参阅playing-movies-with-an-alpha-channel-on-the-ipad。