1
我想查看一個視頻巫婆有一個alpha通道(背景是透明的)。唯一的問題是,我似乎沒有弄清楚如何使播放器的背景透明。我知道我必須使用AVplayer,但我無法訪問它的.view屬性。我如何將它添加到子視圖並添加一個圖層?使用AVPlayer查看透明視頻
NSString *path = [NSString stringWithFormat:@"%@%@", [[NSBundle mainBundle] resourcePath], @"/New Project 5.m4v"];
NSURL *filePath = [NSURL fileURLWithPath:path isDirectory:NO];
moviePlayer = [[AVPlayer alloc] initWithURL:filePath];
AVPlayerLayer* playerLayer = [AVPlayerLayer playerLayerWithPlayer:moviePlayer];
self.playerLayer.frame = self.view.bounds;
moviePlayer.view.alpha = 0.3;
[moviePlayer.layer addSublayer:playerLayer];
[moviePlayer play];
默認情況下不支持alpha通道是正確的,但這裏列出了幾個解決方法:http://stackoverflow.com/questions/1401517/iphone-sdk-how-to-play-a-video -with透明度 – MoDJ 2013-07-25 22:43:07