You can implement your own resolvers based on the default resolvers.
@protocol PTContentResolver <NSObject>
@required
+ (BOOL)shouldHandleOpportunity:(PTPlacementOpportunity *)opportunity;
//Detector returns YES/NO if it should handle the following placement opportunity
- (void)configWithPlayerItem:(PTMediaPlayerItem *)item
delegate:(id<PTContentResolverDelegate> delegate);
- (void)process:(PTPlacementOpportunity *)opportunity;
- (void)timeout:(PTPlacementOpportunity *)opportunity;
//The timeout method gets invoked if the PSDK decides that the
//PTContentResolver is taking too much time to respond.
@end
@interface PTContentResolver : NSObject <PTContentResolver>
@property (readonly) id<PTContentResolverDelegate> delegate;
@property (readonly) PTMediaPlayerItem *playerItem;
- (BOOL)shouldHandleOpportunity:(PTPlacementOpportunity *)opportunity;
- (void)configWithPlayerItem:(PTMediaPlayerItem *)item
delegate:(id<PTContentResolverDelegate>) delegate;
- (void)process:(NSArray *)opportunities;
- (void)cancel:(NSArray *)opportunities;
@end
NSMutableArray *ptBreaks = [[[NSMutableArray alloc] init] autorelease]; // Prepare the primary asset of the ad - links to ad m3u8 PTAdHLSAsset *ptAdAsset = [[[PTAdHLSAsset alloc] init] autorelease]; ptAdAsset.source = AD_SOURCE_M3U8; ptAdAsset.id = FAKE_NUMBER_ID; ptAdAsset.format = @"video"; // Prepare the ad itself. PTAd *ptAd = [[[PTAd alloc] init] autorelease]; ptAd.primaryAsset = ptAdAsset; ptAd.primaryAsset.ad = ptAd; // Prepare the break and add the ad created above. PTAdBreak *ptBreak = [[[PTAdBreak alloc] init] autorelease]; ptBreak.relativeRange = CMTimeRangeMake(BREAK_START_TIME, BREAK_DURATION_VALUE); [ptBreak addAd:ptAd]; // Add the break to array of breaks. [ptBreaks addObject:adBreak]; // Once all breaks have been prepared, they can be set on timeline PTTimeline *_timeline = [[PTTimeline alloc] init]; _timeline.adBreaks = ptBreaks;
//Remove default content/ad resolver [[PTDefaultMediaPlayerFactory defaultFactory] clearContentResolvers]; //Create an instance of your content/ad resolver (id <PTContentResolver>) CustomContentResolver *contentResolver = [[CustomContentResolver alloc] init]; //Set custom content/ad resolver [[PTDefaultMediaPlayerFactory defaultFactory] registerContentResolver:[contentResolver autorelease]];
//Remove default opportunity resolver
[[PTDefaultMediaPlayerFactory defaultFactory] clearOpportunityResolvers];
//Create an instance of your opportunity resolver (id <PTOpportunityResolver>)
CustomOpportunityResolver *opportunityResolver = [[CustomOpportunityResolver alloc] init];
//Set custom opportunity resolver
[[PTDefaultMediaPlayerFactory defaultFactory]
registerOpportunityResolver:[opportunityResolver autorelease]];