2

我想播放具有透明背景的视频。唯一的问题是,我在网上找到的所有信息都是“如何使视频背景透明”,但我的视频背景已经是透明的,现在我需要让播放器的背景透明。我怎么做?我试过这个:

NSString *resourcePath = [[NSBundle mainBundle] pathForResource:@"New Project 5" ofType:@"m4v"];
NSLog(@"%@",resourcePath);
NSURL *url = [NSURL fileURLWithPath:resourcePath];
NSLog(@"%@",url);

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

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

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

[moviePlayer play];

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

但它不起作用。它显示黑色背景。

4

1 回答 1

2

这是一个真正解决此问题的链接,该问题正在播放电影与-一个-alpha-channel-on-the-ipad。她的博客文章谈论的是 iPad 上的视频,但支持 alpha 通道的同一个库也适用于 iPhone。也可以使用博客文章评论中描述的方法编码为具有 alpha 通道支持的 h.264。

于 2013-06-25T20:47:17.357 回答