开发者

Play transparent MOV file in iPhone

I have a 开发者_开发知识库MOV file with alpha channel that is 320x480. I want to play this movie over an image in my view, so that I want the image content to seem like its under the transparent MOV. How can this be done?


Just give the player's view its alpha value as:

[yourPlayer view].backgroundColor = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"back.png"]];
[yourPlayer view].alpha = 0.5;//or any value you think is right

Check out this sample app I've uploaded...you can see the background image through the video...hope it answers your question


You cannot play a video with an alpha channel using built-in iOS libraries. See this question how-to-do-animations-using-images-efficiently-in-ios for a real solution via a library called AVAnimator that enables playback of videos with an alpha channel in an iOS app. You could also take a look at the free app "APNG" in the app store, it is a demo of the same basic technology that makes it possible to embed videos with an alpha channel into the app resources.


I have been working for the video Background for the ios Swift app. Its working fine for me .The working code is below

first import MediaPlayer library

import MediaPlayer

Replace your function with this

override func viewDidLoad () {
  super.viewDidLoad()

  //get the main video file from local
  var path = NSBundle.mainBundle().pathForResource("background", "MOV") 

  var url = NSURL.fileURLWithPath(path)

  var backgroundPlayer: MPMoviePlayerController = MPMoviePlayerController(contentURL: url)

  if backgroundPlayer != nil {
     backgroundPlayer.view.frame = self.view.bounds
     backgroundPlayer.controlStyle = MPMovieControlStyle.None
     backgroundPlayer.prepareToPlay()
     backgroundPlayer.repeatMode = .One
     backgroundPlayer.scalingMode = .AspectFill
     backgroundPlayer.view.alpha = 0.5

     self.view.addSubview(player.view)
  }
}

you can add view over this Video Controller View. //self.view.addSubview()

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜