VideoPlayerSampleView.m 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /* Copyright (C) 2012 IGN Entertainment, Inc. */
  2. #import "VideoPlayerSampleView.h"
  3. @interface VideoPlayerSampleView()
  4. @property (nonatomic, readwrite, strong) UIView *videoPlayerView;
  5. @property (nonatomic, readwrite, strong) UIButton *playFullScreenButton;
  6. @property (nonatomic, readwrite, strong) UIButton *playInlineButton;
  7. @end
  8. @implementation VideoPlayerSampleView
  9. - (id)init
  10. {
  11. if ((self = [super init])) {
  12. self.playInlineButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
  13. [self.playInlineButton setTitle:@"Play Inline" forState:UIControlStateNormal];
  14. [self addSubview:self.playInlineButton];
  15. self.playFullScreenButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
  16. [self.playFullScreenButton setTitle:@"Play Fullscreen" forState:UIControlStateNormal];
  17. [self addSubview:self.playFullScreenButton];
  18. self.videoPlayerView = [[UIView alloc] init];
  19. self.videoPlayerView.autoresizesSubviews = UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth;
  20. [self addSubview:self.videoPlayerView];
  21. self.backgroundColor = [UIColor whiteColor];
  22. }
  23. return self;
  24. }
  25. - (void)layoutSubviews
  26. {
  27. [super layoutSubviews];
  28. CGRect bounds = self.bounds;
  29. self.playInlineButton.frame = CGRectMake((bounds.size.width - 150)/2.0,
  30. (bounds.size.height - 50)/2.0,
  31. 150,
  32. 50);
  33. self.playFullScreenButton.frame = CGRectMake((bounds.size.width - 150)/2.0,
  34. (bounds.size.height + 50)/2.0,
  35. 150,
  36. 50);
  37. CGFloat videoHeight = bounds.size.width * 9 / 16;
  38. self.videoPlayerView.frame = CGRectMake(0, [[UIApplication sharedApplication] statusBarFrame].size.height, bounds.size.width, videoHeight);
  39. }
  40. @end