TVSDK supports resolving and inserting ads for VOD and live/linear streams.
Before you can include advertising in your video content, provide the following metadata information:
mediaID
, which identifies the specific content to play.zoneID
, which identifies your company or website.Your application must provide TVSDK with the required PTAuditudeMetadata
information to connect to the ad server.
To set up the ad server metadata:
Create an instance of PTAuditudeMetadata and set its properties.
PTAuditudeMetadata *adMetadata = [[PTAuditudeMetadata alloc] init];
adMetadata.zoneId = @"INSERT_YOUR_ZONE_ID_HERE";
adMetadata.domain = @"INSERT_YOUR_DOMAIN_HERE";
// Optionally set user agent
adMetadata.userAgent = @"INSERT_AGENT_NAME_HERE;
Set the PTAuditudeMetadata
instance as metadata for the current PTMediaPlayerItem
metadata by using PTAdResolvingMetadataKey
.
// Metadata is an instance of PTMetadata that is used to create the PTMediaPlayerItem
[metadata setMetadata:adMetadata forKey:PTAdResolvingMetadataKey];
[adMetadata release];
Here is an example:
PTMetadata *metadata = [self createMetadata];
PTMediaPlayerItem *item =
[[[PTMediaPlayerItem alloc] initWithUrl:url mediaId:yourMediaID metadata:metadata] autorelease];
- (PTMetadata *) createMetadata {
PTMetadata* metadata = [[[PTMetadata alloc] init] autorelease];
PTAuditudeMetadata *adMetadata = [[[PTAuditudeMetadata alloc] init] autorelease];
adMetadata.zoneId = yourZoneID;
adMetadata.domain = yourAdServerDomain;
[metadata setMetadata:adMetadata forKey:PTAdResolvingMetadataKey];
return metadata;
}