Para implementar la variable PTTimeRangeCollection
y marcar intervalos de contenido como anuncios:
Prepare el PTTimeRangeCollection
.
Defina el tipo de PTTimeRangeCollection
hasta PTTimeRangeCollectionTypeMarkRanges
.
Este paso notifica a TVSDK de que los intervalos personalizados deben tratarse como anuncios.
#define PSDK_TIMESCALE 100000
NSArray *ranges = @[
[PTReplacementRange
replacementRangeWithRange:CMTimeRangeMake(CMTimeMakeWithSeconds
(0, PSDK_TIMESCALE),CMTimeMakeWithSeconds(60, AD_TIMESCALE))],
[PTReplacementRange
replacementRangeWithRange:CMTimeRangeMake(CMTimeMakeWithSeconds
(120, PSDK_TIMESCALE),CMTimeMakeWithSeconds(60, AD_TIMESCALE))]
];
PTTimeRangeCollection *timeRangeCollection =
[[PTTimeRangeCollection alloc] initWithRanges:ranges
type:PTTimeRangeCollectionTypeMarkRanges];
Cree el PTAdMetadata
y configure el PTTimeRangeCollection
.
// Create the PTPlayerItem metadata
PTMetadata *metadata = [[PTMetadata alloc] init];
// Create the Ad metadata
PTAuditudeMetadata *adMetadata = [[PTAuditudeMetadata alloc] init];
adMetadata.timeRangeCollection = timerangeCollection;
//Set Ad metadata
[metadata setMetadata:adMetadata forKey:PTAdResolvingMetadataKey];
//Create PTMediaPlayerItem
PTMediaPlayerItem *playerItem = [[[PTMediaPlayerItem alloc] initWithUrl:mediaUrl
mediaId:mediaId
metadata:metadata];
Cree el reproductor e inicie la reproducción.
//Create PTMediaPlayer using the created PTMediaPlayer
PTMediaPlayer *player = [PTMediaPlayer playerWithMediaPlayerItem:playerItem];
//Add player to the player UIView
[self.playerView addSubview:(UIView *)player.view];
//Start playback
[player play];
Para implementar la variable PTTimeRangeCollection
y elimine intervalos de contenido como anuncios:
Preparar PTTimeRangeCollection
.
Defina el tipo de PTTimeRangeCollection
hasta PTTimeRangeCollectionTypeReplaceRanges
.
Este paso notifica a TVSDK de que los intervalos proporcionados deben reemplazarse por contenido alternativo (anuncios).
#define PSDK_TIMESCALE 100000
NSArray *ranges = @[
[PTReplacementRange replacementRangeWithRange:CMTimeRangeMake(CMTimeMakeWithSeconds
(0, PSDK_TIMESCALE),CMTimeMakeWithSeconds(60, AD_TIMESCALE))
replacementDuration:CMTimeMakeWithSeconds(30, AD_TIMESCALE)],
[PTReplacementRange replacementRangeWithRange:CMTimeRangeMake(CMTimeMakeWithSeconds
(120, PSDK_TIMESCALE),CMTimeMakeWithSeconds(60, AD_TIMESCALE))
replacementDuration:CMTimeMakeWithSeconds(30, AD_TIMESCALE)]
];
PTTimeRangeCollection *timeRangeCollection =
[[PTTimeRangeCollection alloc] initWithRanges:ranges
type:PTTimeRangeCollectionTypeReplaceRanges];
El argumento replacementDuration
es opcional. Si no está definida, la variable AdServer
determina la duración de la pausa publicitaria.
Cree el PTAdMetadata
y configure el PTTimeRangeCollection
.
//Create the PTPlayerItem metadata
PTMetadata *metadata = [[PTMetadata alloc] init];
//Create the Ad metadata
PTAuditudeMetadata *adMetadata = [[PTAuditudeMetadata alloc] init];
adMetadata.timeRangeCollection = timerangeCollection;
adMetadata.zoneId = adZoneId;
adMetadata.domain = adDomain;
adMetadata.signalingMode = PTAdSignalingModeCustomRanges;
//Set Ad metadata
[metadata setMetadata:adMetadata forKey:PTAdResolvingMetadataKey];
//Create PTMediaPlayerItem
PTMediaPlayerItem *playerItem = [[[PTMediaPlayerItem alloc] initWithUrl:mediaUrl
mediaId:mediaId
metadata:metadata];
Aunque la variable signalingMode
se ha establecido como PTAdSignalingModeCustomRanges
, este modo de señalización de publicidad se configura automáticamente al configurar la variable PTTimeRangeCollection
de tipo PTTimeRangeCollectionTypeReplace
.
Cree el reproductor e inicie la reproducción.
//Create PTMediaPlayer using the created PTMediaPlayer
PTMediaPlayer *player = [PTMediaPlayer playerWithMediaPlayerItem:playerItem];
//Add player to the player UIView
[self.playerView addSubview:(UIView *)player.view];
//Start playback
[player play];
Para implementar la variable PTTimeRangeCollection
y elimine intervalos de contenido como anuncios:
Prepare el PTTimeRangeCollection
.
Defina el tipo de PTTimeRangeCollection
hasta PTTimeRangeCollectionTypeDeleteRanges
, que notifica a TVSDK de que es necesario eliminar los intervalos proporcionados.
#define PSDK_TIMESCALE 100000
NSArray *ranges = @[
[PTReplacementRange replacementRangeWithRange:CMTimeRangeMake(CMTimeMakeWithSeconds
(0, PSDK_TIMESCALE),CMTimeMakeWithSeconds(60, AD_TIMESCALE))],
[PTReplacementRange replacementRangeWithRange:CMTimeRangeMake(CMTimeMakeWithSeconds
(120, PSDK_TIMESCALE),CMTimeMakeWithSeconds(60, AD_TIMESCALE))]
];
PTTimeRangeCollection *timeRangeCollection =
[[PTTimeRangeCollection alloc] initWithRanges:ranges
type:PTTimeRangeCollectionTypeDeleteRanges];
Cree el PTAdMetadata
y configure el PTTimeRangeCollection
.
//Create the PTPlayerItem metadata
PTMetadata *metadata = [[PTMetadata alloc] init];
//Create the Ad metadata
PTAuditudeMetadata *adMetadata = [[PTAuditudeMetadata alloc] init];
adMetadata.timeRangeCollection = timerangeCollection;
adMetadata.zoneId = adZoneId;
adMetadata.domain = adDomain;
adMetadata.signalingMode = PTAdSignalingModeServerMap;
//Set Ad metadata
[metadata setMetadata:adMetadata forKey:PTAdResolvingMetadataKey];
//Create PTMediaPlayerItem
PTMediaPlayerItem *playerItem = [[[PTMediaPlayerItem alloc] initWithUrl:mediaUrl
mediaId:mediaId
metadata:metadata];
La inserción de anuncios se produce después de eliminar los intervalos personalizados basados en el PTAdMetadata
y el actual PTAdSignalingMode
.
Cree el reproductor e inicie la reproducción.
//Create PTMediaPlayer using the created PTMediaPlayer
PTMediaPlayer *player = [PTMediaPlayer playerWithMediaPlayerItem:playerItem];
//Add player to the player UIView
[self.playerView addSubview:(UIView *)player.view];
//Start playback
[player play];