Advertising

Brid SDK custom ad integration

BridSDK gives you the factory methods to pair the player with ads that you set up in BRID CMS. If you need integration of custom ads this section is all about it.

playAdTagUrl

Ad Tag Url instant play. On method playAd() call, player will instantly play ad with custom url.

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

@property (nonatomic) BVPlayer *player;

@end

@implementation ViewController

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

- (void)playAd {
    [self.player playAdTagUrl:<url: URL>];
}

@end
import UIKit
import BridSDK

class ViewController: UIViewController {
    
    var player: BVPlayer?

    override func viewDidLoad() {
        super.viewDidLoad()
      
        //Init player
        player = BVPlayer(data: BVData(playerID: <Int32>, forVideoID: <Int32>), for: <UIView>)  
    }
  
    //Method for trigger custom ad url
    func playAd() {
        player.playAdTagUrl(<url: URL>)
    }

}

playAd

Ad Object instant play. On method playAd() call, player will instantly play ad Object.

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

@property (nonatomic) BVPlayer *player;

@end

@implementation ViewController

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

//Method for trigger custom ad object
- (void)playAd {
  
  //create AdData object
  Mobile *mobile = [[Mobile alloc] initWithMobile:"<id>" url:"<yourAdTagUrlFromPrebid>"]
  NSMutableArray<Mobile*> *mobileArray = [[NSMutableArray alloc] init];
  [mobileArray addObject:mobile]; 
  NSMutableArray<mobileArray*> *adPod = [[NSMutableArray alloc] init];
  
  //For preroll set adType to "0", for midroll set adType to "1", for postroll set adType tp "2"
  AdData *adData = [[AdData alloc] initWithAdType:"1" overlayStartAt:nil  overlayDuration:nil adTimeType:nil cuepoints:nil mobile:adPod];

  
 [self.player playAd:adData];
}

@end
import UIKit
import BridSDK

class ViewController: UIViewController {
    
    var player: BVPlayer?

    override func viewDidLoad() {
        super.viewDidLoad()
      
        //Init player
        player = BVPlayer(data: BVData(playerID: <Int32>, forVideoID: <Int32>), for: <UIView>)  
    }
  
    //Method for trigger custom ad object
    func playAd() {
    
        //create AdData object
        let mobile = Mobile(mobile: "<id>", url: "<yourAdTagUrl>") 
        var mobileArray = [Mobile]()
        mobileArray.append(mobile!) 
        let adPod = [mobileArray]
        let adData = AdData(adType: "1", overlayStartAt: nil, overlayDuration: nil, adTimeType: nil, cuepoints: nil, mobile: adPod)
    
        player.playAd(ad: adData) 
    }

}

setAd

Temproray change ad.
On method changeAd() call, player will change configuration for ads on next and previous videos, and it will not affect on ads for current video.

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

@property (nonatomic) BVPlayer *player;

@end

@implementation ViewController

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

//Method for trigger custom ad object
- (void)changeAd {
  
  //create AdData object
  Mobile *mobile = [[Mobile alloc] initWithMobile:"<id>" url:"<yourAdTagUrlFromPrebid>"]
  NSMutableArray<Mobile*> *mobileArray = [[NSMutableArray alloc] init]; 
  NSMutableArray<AdData*> *adArray = [[NSMutableArray alloc] init];
  [mobileArray addObject:mobile]; 
  NSMutableArray<mobileArray*> *adPod = [[NSMutableArray alloc] init];
  
  //For preroll set adType to "0", for midroll set adType to "1", for postroll set adType tp "2"
  AdData *adData = [[AdData alloc] initWithAdType:"1" overlayStartAt:nil  overlayDuration:nil adTimeType:nil cuepoints:nil mobile:adPod];
 [adArray addObject:adData];
  
 [self.player setAd:<ad: [AdData]>];
}

@end
import UIKit
import BridSDK

class ViewController: UIViewController {
    
    var player: BVPlayer?

    override func viewDidLoad() {
        super.viewDidLoad()
      
        //Init player
        player = BVPlayer(data: BVData(playerID: <Int32>, forVideoID: <Int32>), for: <UIView>)  
    }
  
    //Method for trigger custom ad object
    func changedAd() {
    
        //create AdData object
         let mobile = Mobile(mobile: "<id>", url: "<yourAdTagUrl>") 
        var mobileArray = [Mobile]() 
        var adArray = [AdData]() 
        mobileArray.append(mobile!) 
        let adPod = [mobileArray]
    
        //For preroll set adType to "0", for midroll set adType to "1", for postroll set adType tp "2"
        let adData = AdData(adType: "1", overlayStartAt: nil, overlayDuration: nil, adTimeType: nil, cuepoints: nil, mobile: adPod)
        adArray.append(adData!)
    
        player.setAd(<ad: [AdData]>)
    }

}

initPrebid

Initialize the Brid player with a prebid object fro PreRoll:
For prebid implementations, you need to create an ad object with an ad url that you get as a response from your prebid server. We also provide you with an option to create a custom video object and initialize a Brid player with a prebid ad tag url. For playlists, prebid ads will be initalized for all videos present in the list.

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

@property (nonatomic) BVPlayer *player;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
  
    //create AdData object
    Mobile *mobile = [[Mobile alloc] initWithMobile:"<id>" url:"<yourAdTagUrlFromPrebid>"]
    NSMutableArray<Mobile*> *mobileArray = [[NSMutableArray alloc] init]; 
    NSMutableArray<AdData*> *adArray = [[NSMutableArray alloc] init];
    [mobileArray addObject:mobile]; 
    NSMutableArray<mobileArray*> *adPod = [[NSMutableArray alloc] init];
  
    //For preroll set adType to "0", for midroll set adType to "1", for postroll set adType tp "2"
    AdData *adData = [[AdData alloc] initWithAdType:"1" overlayStartAt:nil  overlayDuration:nil adTimeType:nil cuepoints:nil mobile:adPod];
    [adArray addObject:adData];
  
    //Init player
    player = [[BVPlayer alloc] initPrebid:adArray playerID:<playerID> forVideoID:<videoID> forView:<yourView>];
}

@end
import UIKit
import BridSDK

class ViewController: UIViewController {
    
    var player: BVPlayer?

    override func viewDidLoad() {
        super.viewDidLoad()
        //create AdData object
        let mobile = Mobile(mobile: "<id>", url: "<yourAdTagUrl>") 
        var mobileArray = [Mobile]() 
        var adArray = [AdData]() 
        mobileArray.append(mobile!) 
        let adPod = [mobileArray]
      
        //For preroll set adType to "0", for midroll set adType to "1", for postroll set adType tp "2"
        let adData = AdData(adType: "1", overlayStartAt: nil, overlayDuration: nil, adTimeType: nil, cuepoints: nil, mobile: adPod)
        adArray.append(adData!)
      
        //Init player
        player = BVPlayer(prebid: adArray, playerID: playerID, forVideoID: videoID, for: yourView)
    }
  
}

setPrebidForMidroll

Set prebid object for midRoll ad:

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

@property (nonatomic) BVPlayer *player;

@end

@implementation ViewController

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

- (void)setMidRollPrebid {
    [self.player setPrebidForPostroll:(adTagUrl: "<yourTagurl>")]; 
}

@end
import UIKit
import BridSDK

class ViewController: UIViewController {
    
    var player: BVPlayer?

    override func viewDidLoad() {
        super.viewDidLoad()
      
        //Init player
        player = BVPlayer(data: BVData(playerID: <Int32>, forVideoID: <Int32>), for: <UIView>)
    }
  
    //Method for trigger custom ad url
    func setMidRollPrebid() {
        player.setPrebidForMidroll(adTagUrl: "<yourTagurl>")
    }

}

setPrebidForPostroll

Set prebid object for postRoll ad:

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

@property (nonatomic) BVPlayer *player;

@end

@implementation ViewController

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

- (void)setPostRollPrebid {
    [self.player setPrebidForPostroll:(adTagUrl: "<yourTagurl>")]; 
}

@end
import UIKit
import BridSDK

class ViewController: UIViewController {
    
    var player: BVPlayer?

    override func viewDidLoad() {
        super.viewDidLoad()
      
        //Init player
        player = BVPlayer(data: BVData(playerID: <Int32>, forVideoID: <Int32>), for: <UIView>)
    }
  
    //Method for trigger custom ad url
    func setPostRollPrebid() {
        player.setPrebidForPostroll(adTagUrl: "<yourTagurl>")
    }

}

initCustomVideoWithPrebid

Initialize player prebid with custom video object:

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

@property (nonatomic) BVPlayer *player;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
  
    //create AdData object
    Mobile *mobile = [[Mobile alloc] initWithMobile:"<id>" url:"<yourAdTagUrlFromPrebid>"]
    NSMutableArray<Mobile*> *mobileArray = [[NSMutableArray alloc] init]; 
    NSMutableArray<AdData*> *adArray = [[NSMutableArray alloc] init];
    [mobileArray addObject:mobile]; 
    NSMutableArray<mobileArray*> *adPod = [[NSMutableArray alloc] init];
  
    //For preroll set adType to "0", for midroll set adType to "1", for postroll set adType tp "2"
    AdData *adData = [[AdData alloc] initWithAdType:"1" overlayStartAt:nil  overlayDuration:nil adTimeType:nil cuepoints:nil mobile:adPod];
    [adArray addObject:adData];
  
    //Create video objects
    Source *source = [[Source alloc] init];
    source.sd = @"<yourVideoUrl>"
    VideoData *videoObject = [[VideoData alloc] initWithVideo:<videoID> duration:"<durationVideo>" ageGateId:nil name:"nameOfVideo" _description:"<decription>" image:"<image>" thumbnail:"<imageThumbnail>" clickthroughUrl:nil thumb:<"<imageThumb>"> publish:nil mimeType:nil webp:nil monetize:nil liveimage:nil secureUrl:nil source:source traxcks:nil];
    NSMutableArray<VideoData *> *arrayVideo = [[NSMutableArray alloc] init];
    [arrayVideo addObject:videoObject];
  
    //Init player
    player = [[BVPlayer alloc] initCustomVideoWithPrebid:<adArray> playerID:<playerID> videoDataArray:<arrayVideo> forView:<yourView>];
}

@end
import UIKit
import BridSDK

class ViewController: UIViewController {
    
    var player: BVPlayer?

    override func viewDidLoad() {
        super.viewDidLoad()
        
        //create AdData object
        let mobile = Mobile(mobile: "<id>", url: "<yourAdTagUrl>") 
        var mobileArray = [Mobile]() 
        var adArray = [AdData]() 
        mobileArray.append(mobile!) 
        let adPod = [mobileArray]

        //Create video objects
        let source = Source()
        source.sd = "<yourVideoUrl>"
        let videoObject = VideoData(video: <videoID>, duration: "<durationVideo>", ageGateId: nil, name: "nameOfVideo", _description: "<decription>", image: "<image>", thumbnail: "<imageThumbnail>", clickthroughUrl: nil, thumb: "<imageThumb>", publish: nil, mimeType: nil, webp: nil, monetize: nil, liveimage: nil, secureUrl: nil, source: source, tracks: nil)
        var arrayVideo = [VideoData]()
        arrayVideo.append(videoObject)
      
        //For preroll set adType to "0", for midroll set adType to "1", for postroll set adType tp "2"
        let adData = AdData(adType: "1", overlayStartAt: nil, overlayDuration: nil, adTimeType: nil, cuepoints: nil, mobile: adPod)
        adArray.append(adData!)
      
        //Init player
        player = BVPlayer(customVideoWithPrebid: adArray, playerID: playerID, videoDataArray: arrayVideo, for: yourView)
    }
  
}

setAdMacros

Custom set ad macors.

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

@property (nonatomic) BVPlayer *player;

@end

@implementation ViewController

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

- (void)adMacros {
    AdMacros *macros = [[AdMacros alloc] initAdMacrosUserAgent:<NSString> referrerUrl:<NSString> pageUrl:<NSString> appStoreUrl:<NSString>];
  
    [_player setAdMacros:macros];
}

@end
import UIKit
import BridSDK

class ViewController: UIViewController {
    
    var player: BVPlayer?

    override func viewDidLoad() {
        super.viewDidLoad()
      
        //Init player
        player = BVPlayer(data: BVData(playerID: <Int32>, forVideoID: <Int32>), for: <UIView>)
    }
  
    //Method for trigger custom ad url
    func adMacros() {
        let macros = AdMacros(adMacrosUserAgent: <String>, referrerUrl: <String>, pageUrl: <String>, appStoreUrl: <String>)
        
        player.setAdMacros(macros)
    }

}

📘

When creating AdMacros object, proprety inside of object are _Nullable.


Did this page help you?