Advertisement
Guest User

Untitled

a guest
Nov 25th, 2014
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.76 KB | None | 0 0
  1. NSString *filepath = [[NSBundle mainBundle] pathForResource:@"My Movie" ofType:@"mp4"];
  2.  
  3. NSURL *fileURL = [NSURL fileURLWithPath:filepath];
  4. AVPlayer *player = [AVPlayer playerWithURL:fileURL];
  5.  
  6. AVPlayerLayer *layer = [AVPlayerLayer playerLayerWithPlayer:player];
  7.  
  8. UIImageView *logoTop =[[UIImageView alloc] initWithFrame:CGRectMake(20,50,280,99)];
  9. logoTop.image=[UIImage imageNamed:@"logo.png"];
  10.  
  11. self.mylabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 100, 320, 300)];
  12. self.mylabel.text = @"Some text here";
  13. self.mylabel.textColor = [UIColor whiteColor];
  14. [self.mylabel setTextAlignment:NSTextAlignmentCenter];
  15. [self.mylabel setFont:[UIFont systemFontOfSize:36]];
  16. self.mylabel.numberOfLines = 5;
  17. self.mylabel.shadowColor = [UIColor blackColor];
  18. self.mylabel.shadowOffset = CGSizeMake(0,1);
  19.  
  20. UIButton *loginButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
  21. [loginButton addTarget:self
  22. action:@selector(Method_login:)
  23. forControlEvents:UIControlEventTouchUpInside];
  24. [loginButton setTitle:@"Show View" forState:UIControlStateNormal];
  25. loginButton.frame = CGRectMake(80.0, 80.0, 60, 60);
  26.  
  27. [layer setVideoGravity:AVLayerVideoGravityResizeAspectFill];
  28. player.actionAtItemEnd = AVPlayerActionAtItemEndNone;
  29. layer.frame = CGRectMake(0, 0, 320, 600);
  30.  
  31. [_videoSuper.layer addSublayer: layer];
  32. [layer addSublayer:self.mylabel.layer];
  33. [layer addSublayer:logoTop.layer];
  34. [layer addSublayer:loginButton.layer];
  35.  
  36. player.actionAtItemEnd = AVPlayerActionAtItemEndNone;
  37.  
  38. [[NSNotificationCenter defaultCenter] addObserver:self
  39. selector:@selector(playerItemDidReachEnd:)
  40. name:AVPlayerItemDidPlayToEndTimeNotification
  41. object:[player currentItem]];
  42.  
  43. [player play];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement