iPad Video with Transparency

后端 未结 5 1719
一生所求
一生所求 2020-12-15 05:11

is it possible to have a QuickTime video with alpha layer (transparency) play on top of a static dynamic background UIView (i.e. a view that changes occasionall

相关标签:
5条回答
  • 2020-12-15 05:43

    You could have a normal video and reduce the alpha of the presenting view. This can be done using an AVPlayer and AVPlayerLayer by adding the AVPlayerLayer to a UIView and setting the alpha of the UIView. Something like:

    self.player = [[AVPlayer alloc] initWithURL:url];
    self.playerLayer = [AVPlayerLayer playerLayerWithPlayer:self.player];
    self.playerLayer.frame = view.bounds;
    ...etc...
    self.playerView.alpha = 0.3;
    [self.playerView.layer addSublayer:self.playerLayer];
    

    I haven't tried this with the alpha channel in the video itself, but AVPlayerLayer should work for that as well.

    0 讨论(0)
  • 2020-12-15 05:51

    I think you can make videos transparent , while playing the video adjust the alpha of view from 0.0 to 1.0. for eg 0.50. After playing the vido change the alpha of view to 1.0.

    0 讨论(0)
  • 2020-12-15 05:52

    first your video needs transparency: http://docs.info.apple.com/article.html?artnum=42599

    IMHO: I think the videocomponent has a solid background color (black) you will have to set it to [UIColor clearColor] You have to try, im not sure if that works.

    cheers endo

    0 讨论(0)
  • 2020-12-15 05:53

    MPMoviePlayerController has a backgroundView property. The docs state:

    This view provides the backing content, on top of which the movie content is displayed. You can add subviews to the background view if you want to display custom background content.

    I haven't tried it, but if the video content itself has alpha, it sounds like this view should show up. If you set that view to clear, it may just work...

    0 讨论(0)
  • 2020-12-15 06:01

    Just to clear up the misinformation, you can't use a video with an alpha channel using the built in video logic in iOS. You can create a Quicktime movie encoded with the Animation codec and load the video into a view or layer using AVAnimator. What you can't do is create a H264 video with an alpha channel, that is simply is not supported by iOS.

    display movies with an alpha channel under iOS

    0 讨论(0)
提交回复
热议问题