Advertisement
Guest User

Untitled

a guest
May 25th, 2018
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //
  2. //  ViewController.m
  3. //  CCDemo
  4. //
  5. //  Created by Nissim Pardo on 02/06/2016.
  6. //  Copyright © 2016 kaltura. All rights reserved.
  7. //
  8.  
  9. #import "ViewController.h"
  10.  
  11.  
  12. @interface ViewController () {
  13.     BOOL _isFullScreen;
  14. }
  15. @property (nonatomic, weak) IBOutlet UIView *playerHolderView;
  16. @property (nonatomic, strong) KPViewController *player;
  17. @property (nonatomic, strong) GoogleCastProvider *castProvider;
  18. @property (weak, nonatomic) IBOutlet UINavigationItem *navItem;
  19. @end
  20.  
  21. @implementation ViewController
  22.  
  23. - (void)viewDidLoad {
  24.     [super viewDidLoad];
  25.     // Do any additional setup after loading the view, typically from a nib.
  26.    
  27.     CGRect frame = CGRectMake(0, 0, 24, 24);
  28.     GCKUICastButton *castButton = [[GCKUICastButton alloc] initWithFrame:frame];
  29.     castButton.tintColor = [UIColor blueColor];
  30.     UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithCustomView:castButton];
  31.     self.navItem.rightBarButtonItem = item;
  32. }
  33. - (IBAction)changeMedia:(id)sender {
  34.     if (_player) {
  35.         [_player changeMedia:@"0_bdo3b1nx"];
  36.     }
  37. }
  38.  
  39. - (IBAction)loadPlayer:(UIButton *)sender {
  40.    
  41.     if(_player != nil) {
  42.         [_player removePlayer];
  43.     }
  44.     KPPlayerConfig *config = [[KPPlayerConfig alloc] initWithServer:@"http://open.http.mp.streamamg.com/"
  45.                                                                uiConfID:@"30025712"
  46.                                                               partnerId:@"3000034"];
  47.     config.entryId = @"0_2cfwowez";
  48.     [config addConfigKey:@"chromecast.plugin" withValue:@"true"];
  49.     [config addConfigKey:@"chromecast.useKalturaPlayer" withValue:@"true"];
  50.    
  51.  
  52.     _player = [[KPViewController alloc] initWithConfiguration:config];
  53.     _castProvider = [[GoogleCastProvider alloc] init];
  54.     [self addChildViewController:_player];
  55.     _player.view.frame = _playerHolderView.bounds;
  56.     [_player setDelegate:self];
  57.     [_player loadPlayerIntoViewController:self];
  58.     [_player.playerController play];
  59.     [_playerHolderView addSubview:_player.view];
  60.    
  61.    
  62.     [[NSNotificationCenter defaultCenter]   addObserver:self
  63.                                                selector:@selector(appWillTerminate:)
  64.                                                    name:UIApplicationWillTerminateNotification
  65.                                                  object:[UIApplication sharedApplication]];
  66.    
  67. }
  68.  
  69. - (IBAction)startCasting:(UIBarButtonItem *)sender {
  70.     sender.tag = sender.tag ? 0 : 1;
  71.     _player.castProvider = _castProvider;
  72. }
  73.  
  74. - (IBAction)load360Player:(id)sender {
  75.     if(_player != nil) {
  76.         [_player removePlayer];
  77.     }
  78.     KPPlayerConfig *config = [[KPPlayerConfig alloc] initWithServer:@"http://open.http.staging-k9.streamuk.com/"
  79.                                                            uiConfID:@"30000822"
  80.                                                           partnerId:@"3000021"];
  81.     config.entryId = @"0_0e7pen8s";
  82.     [config addConfigKey:@"chromecast.plugin" withValue:@"true"];
  83.     [config addConfigKey:@"chromecast.useKalturaPlayer" withValue:@"true"];
  84.    
  85.     _player = [[KPViewController alloc] initWithConfiguration:config];
  86.     //     _castProvider = [[GoogleCastProvider alloc] init];
  87.     [self addChildViewController:_player];
  88.     _player.view.frame = _playerHolderView.bounds;
  89.     [_player setDelegate:self];
  90.     [_player loadPlayerIntoViewController:self];
  91.     [_player.playerController play];
  92.     [_playerHolderView addSubview:_player.view];
  93.    
  94.     [[NSNotificationCenter defaultCenter]   addObserver:self
  95.                                                selector:@selector(appWillTerminate:)
  96.                                                    name:UIApplicationWillTerminateNotification
  97.                                                  object:[UIApplication sharedApplication]];
  98. }
  99.  
  100. - (void)kPlayer:(KPViewController *)player playerFullScreenToggled:(BOOL)isFullScreen {
  101.     _isFullScreen = isFullScreen;
  102. }
  103.  
  104. - (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
  105.     if((UIInterfaceOrientationIsLandscape(toInterfaceOrientation) && !_isFullScreen)) {
  106.         [_player toggleFullscreen];
  107.     } else if((UIInterfaceOrientationIsPortrait(toInterfaceOrientation) && _isFullScreen)) {
  108.         [_player toggleFullscreen];
  109.        
  110.     }
  111. }
  112.  
  113.  
  114. - (void)appWillTerminate:(NSNotification *)note {
  115.     NSLog(@"terminate");
  116. }
  117.  
  118.  
  119. - (UIColor *)defaultTint {
  120.     return [UIColor colorWithRed:0
  121.                            green:122.0 / 255.0
  122.                             blue:1
  123.                            alpha:1];
  124. }
  125.  
  126. - (void)didReceiveMemoryWarning {
  127.     [super didReceiveMemoryWarning];
  128.     // Dispose of any resources that can be recreated.
  129. }
  130.  
  131. @end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement