Add player to your view

Use the following steps and code examples to add a player to the ViewController.h or ViewController.swift file of your app:

  • In ViewController.h or ViewController.swift import BridSDK
  • Declare a variable BVPlayer named player
  • Create AVPlayerViewController named playerController
  • Present view contorller
#import "ViewController.h"
#import <BridSDK/BridSDK.h>
  
@interface ViewController ()

@property (nonatomic) BVPlayer *player;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    AVPlayerViewController *playerController = [[AVPlayerViewController alloc] init];
  
    //init player
    _player = [[BVPlayer alloc] initWithData:[[BVData alloc] initPlayerID: <Int32> forPlaylistID: <Int32>] forAvController:playerController];
    
    //present player
    [self presentViewController:playerController animated:YES completion:nil];
    
}

@end
import UIKit
import BridSDK

class ViewController: UIViewController {
    
    var player: BVPlayer?
    var playerController: AVPlayerViewController?

    override func viewDidLoad() {
        super.viewDidLoad()
        
      	self.playerController = AVPlayerViewController.init()
      
        //init player
        player = BVPlayer(data: BVData(playerID: 24282, forVideoID: 442011), forAvController: self.playerController)
      
        //present player
        self.present(playerController!, animated: true, completion: nil)	
    }

}

What’s Next