Player public events

Listen to events from player:

You can listen to events of the player through the Notification Centre. There are player events and ad events. Just change the string in notification.usreInfo.

#import "ViewController.h"
#import <BridSDK/BridSDK.h>
  
@interface ViewController ()

@property (nonatomic) BVPlayer *player;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    player = [[BVPlayer alloc] initWithData:[[BVData alloc] initPlayerID:<int> forVideoID:<int>] forView:<UIView>]
    [self setupEventNetworking];
    
}

- (void)setupEventNetworking {   
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(eventWriter:) name:@"PlayerEvent" object:nil];   
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(eventWriter:) name:@"AdEvent" object:nil];    
}  

- (void) eventWriter:(NSNotification *)notification {
    if ([notification.name isEqualToString:@"PlayerEvent"]) {  
        [self logMessage:(NSString *)notification.userInfo[@"event"]]; 
    }  
    if ([notification.name isEqualToString:@"AdEvent"]) { 
        [self logMessage:(NSString *)notification.userInfo[@"ad"]];  
    }  
}  

@end
import UIKit
import BridSDK

class ViewController: UIViewController {
    
    var player: BVPlayer?

    override func viewDidLoad() {
        super.viewDidLoad()
                player = BVPlayer(data: BVData(playerID: <Int32>, forVideoID: <Int32>), for: <UIView>)  
      setupEventNetworking()
    }
  
  func setupEventNetworking() {  
       NotificationCenter.default.addObserver(self, selector: #selector(eventWriter), name:NSNotification.Name(rawValue: "PlayerEvent"), object: nil) 
       NotificationCenter.default.addObserver(self, selector: #selector(eventWriter), name:NSNotification.Name(rawValue: "AdEvent"), object: nil) 
}
  
@objc func eventWriter(_ notification: NSNotification) {       
    if notification.name.rawValue == "PlayerEvent" {
        print(notification.userInfo?["event"] as! String)
    }  
    if notification.name.rawValue == "AdEvent" {   
        print(notification.userInfo?["ad"] as! String)
    }   
}

}

Player events which can be listened:

sec (player time in second)

Play (player play video)

Pause (player pause video)

Stop (player stop video)

Next (player next video)

Previous (player previous video)

PlayerInitalized (player is initalized)

SetupVideo (video is initalized)

MuteVideo (video is muted)

UnMuteVideo (video is unmuted)

VideoEnded (video is ended)

Ad events which can be listened:

adLoaded (parser loaded ad)

adStarted (ad video started)

adFirstQuartile (ad first quartile)

adMidpoint (ad midpoint)

adThrid Quartile (ad thrid quartile)

adComplete (ad complete)

adError (ad return error)

adSkipped (ad skipped)

adPaused (ad paused)

adResume (ad resume)

adTapped (ad tapped)


Did this page help you?