Player public events

Listen to events from player:

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

#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)
    }   
}

}

Available player events:

sec (player time in seconds)
Play (player play video)
Pause (player pause video)
Stop (player stop video)
Next (player next video)
Previous (player previous video)
PlayerInitialized (player is initialised)
SetupVideo (video is initialised)
MuteVideo (video is muted)
UnMuteVideo (video is unmuted)
VideoEnded (video is ended)

Available player advertising events:

adLoaded (parser loaded ad)
adStarted (ad video started)
adFirstQuartile (ad first quartile)
adMidpoint (ad midpoint)
adThird Quartile (ad third 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?