LXMViewController.m 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. //
  2. // LXMViewController.m
  3. // LXMPlayer
  4. //
  5. // Created by billthas@gmail.com on 08/28/2018.
  6. // Copyright (c) 2018 billthas@gmail.com. All rights reserved.
  7. //
  8. #import "LXMViewController.h"
  9. #import <LXMPlayer/LXMPlayer.h>
  10. @interface LXMViewController ()
  11. @property (nonatomic, strong) LXMAVPlayerView *playerView;
  12. @end
  13. @implementation LXMViewController
  14. - (void)viewDidLoad {
  15. [super viewDidLoad];
  16. // Do any additional setup after loading the view, typically from a nib.
  17. CGRect bounds = [[UIScreen mainScreen] bounds];
  18. LXMAVPlayerView *testView = [[LXMAVPlayerView alloc] initWithFrame:CGRectMake(0, 44, bounds.size.width, bounds.size.width / 16 * 9)];
  19. // [testView setPlayerTimeDidChangeBlock:^(NSTimeInterval currentTime, NSTimeInterval totalTime) {
  20. // NSLog(@"PlayerTimeDidChangeBlock: %@, %@", @(currentTime), @(totalTime));
  21. // }];
  22. [testView setPlayerStatusDidChangeBlock:^(LXMAVPlayerStatus status) {
  23. NSLog(@"PlayerStatusDidChangeBlock: %@", @(status));
  24. }];
  25. [testView setPlayerDidPlayToEndBlock:^(AVPlayerItem *item) {
  26. NSLog(@"PlayerDidPlayToEndBlock");
  27. }];
  28. self.playerView = testView;
  29. testView.backgroundColor = UIColor.orangeColor;
  30. [self.view addSubview:testView];
  31. NSLog(@"%@",testView);
  32. }
  33. - (void)didReceiveMemoryWarning {
  34. [super didReceiveMemoryWarning];
  35. // Dispose of any resources that can be recreated.
  36. }
  37. #pragma mark - Action
  38. - (IBAction)handlePlayButtonTapped:(id)sender {
  39. NSString *testUrl = @"https://media.w3.org/2010/05/sintel/trailer.mp4";
  40. NSURL *url = [NSURL URLWithString:testUrl];
  41. self.playerView.assetURL = url;
  42. [self.playerView play];
  43. }
  44. - (IBAction)handlePauseButtonTapped:(id)sender {
  45. [self.playerView pause];
  46. }
  47. @end