Reproducción de VOD con un capítulo vod-playback-with-one-chapter
Escenario scenario
En esta situación, una parte del contenido de VOD se marca como capítulo.
Si no se indica lo contrario, las llamadas de red en este escenario son iguales a las llamadas que se hacen en el escenario de Reproducción de VOD sin anuncios. La llamada de red se realiza al mismo tiempo, pero la carga útil es distinta.
trackSessionStart
trackEvent:ChapterStart
trackPlay
trackEvent:trackChapterComplete
trackComplete
trackSessionEnd
SessionEnd
significa que se ha llegado al final de una sesión de visualización. Hay que invocar a esta API aunque el usuario no vea el contenido completo.Parámetros parameters
Cuando comienza la reproducción del capítulo, se envía una llamada de Heartbeat Chapter Start
. Si el principio del capítulo no coincide con el temporizador de 10 segundos, la llamada de Heartbeat Chapter Start
se retrasa unos segundos y pasa al siguiente intervalo de 10 segundos.
Cuando esto sucede, se produce una llamada de Content Heartbeat
en el mismo intervalo. Puede diferenciar una de otra fijándose en el tipo de evento y el tipo de recurso:
Inicio de capítulo de Heartbeat
s:event:type
"chapter_start"
s:asset:type
"main"
s:stream:chapter_*
s:meta:*
Código de muestra: capítulo en medio sample-code-chapter-in-the-middle
En esta situación, parte del contenido de VOD es un capítulo.
Android
Para ver este caso en Android, configure el siguiente código:
// Set up mediaObject
MediaObject mediaInfo = MediaHeartbeat.createMediaObject(
Configuration.MEDIA_NAME,
Configuration.MEDIA_ID,
Configuration.MEDIA_LENGTH,
MediaHeartbeat.StreamType.VOD
);
HashMap<String, String> mediaMetadata = new HashMap<String, String>();
mediaMetadata.put(CUSTOM_KEY_1, CUSTOM_VAL_1);
mediaMetadata.put(CUSTOM_KEY_2, CUSTOM_VAL_2);
// 1. Call trackSessionStart() when the user clicks Play or if autoplay is used,
// i.e., there is an intent to start playback.
_mediaHeartbeat.trackSessionStart(mediaInfo, mediaMetadata);
......
......
// 2. Call trackPlay() when the playback actually starts, i.e., first frame of the
// ad media is rendered on the screen.
_mediaHeartbeat.trackPlay();
.......
.......
// Chapter
HashMap<String, String> chapterMetadata = new HashMap<String, String>();
chapterMetadata.put(CUSTOM_KEY_1, CUSTOM_VAL_1);
MediaObject chapterDataInfo =
MediaHeartbeat.createChapterObject(CHAPTER_NAME,
CHAPTER_POSITION,
CHAPTER_LENGTH,
CHAPTER_START_TIME);
// 3. Track the MediaHeartbeat.Event.ChapterStart event when the chapter starts to play.
_mediaHeartbeat.trackEvent(MediaHeartbeat.Event.ChapterStart, chapterDataInfo, chapterMetadata);
.......
.......
// 4. Track the MediaHeartbeat.Event.ChapterComplete event when the chapter finishes playing.
_mediaHeartbeat.trackEvent(MediaHeartbeat.Event.ChapterComplete, null, null);
.......
.......
// 5. Call trackComplete() when the playback reaches the end, i.e., completes and finishes playing.
_mediaHeartbeat.trackComplete();
........
........
// 6. Call trackSessionEnd() when the playback session is over. This method must be called even
// if the user does not watch the media to completion.
_mediaHeartbeat.trackSessionEnd();
........
........
iOS
Para ver este caso en iOS, configure el siguiente código:
when the user clicks Play
ADBMediaObject *mediaObject =
[ADBMediaHeartbeat createMediaObjectWithName:MEDIA_NAME
length:MEDIA_LENGTH
streamType:ADBMediaHeartbeatStreamTypeVOD];
NSMutableDictionary *mediaContextData = [[NSMutableDictionary alloc] init];
[mediaContextData setObject:CUSTOM_VAL_1 forKey:CUSTOM_KEY_1];
[mediaContextData setObject:CUSTOM_VAL_2 forKey:CUSTOM_KEY_2];
// 1. Call trackSessionStart when the user clicks Play or if autoplay is used,
// i.e., when there is an intent to start playback.
[_mediaHeartbeat trackSessionStart:mediaObject data:mediaContextData];
.......
.......
// 2. Call trackPlay when the playback actually starts, i.e., when the
// first frame of the main content is rendered on the screen.
[_mediaHeartbeat trackPlay];
.......
.......
// Chapter
NSMutableDictionary *chapterContextData = [[NSMutableDictionary alloc] init];
[chapterContextData setObject:CONTEXT_DATA_VALUE forKey:CONTEXT_DATA_KEY];
id chapterInfo =
[ADBMediaHeartbeat createChapterObjectWithName:CHAPTER_NAME
position:CHAPTER_POSITION
length:CHAPTER_LENGTH
startTime:CHAPTER_START_TIME];
// 3. Track the ADBMediaHeartbeatEventChapterStart event when the chapter
// starts to play.
[_mediaHeartbeat trackEvent:ADBMediaHeartbeatEventChapterStart
mediaObject:chapterInfo
data:chapterContextData];
.......
.......
// 4. Track the ADBMediaHeartbeatEventChapterComplete event when the chapter
// finishes playing.
[_mediaHeartbeat trackEvent:ADBMediaHeartbeatEventChapterComplete
mediaObject:nil
data:nil];
.......
.......
// 5. Call trackComplete when the playback reaches the end, i.e., when the
// media completes and finishes playing.
[_mediaHeartbeat trackComplete];
.......
.......
// 6. Call trackSessionEnd when the playback session is over. This method must
// be called even if the user does not watch the media to completion.
[_mediaHeartbeat trackSessionEnd];
.......
.......
JavaScript
Para ver esta situación en JavaScript, escriba el siguiente texto:
// Set up mediaObject
var mediaInfo = MediaHeartbeat.createMediaObject(
Configuration.MEDIA_NAME,
Configuration.MEDIA_ID,
Configuration.MEDIA_LENGTH,
MediaHeartbeat.StreamType.VOD
);
var mediaMetadata = {
CUSTOM_KEY_1 : CUSTOM_VAL_1,
CUSTOM_KEY_2 : CUSTOM_VAL_2,
CUSTOM_KEY_3 : CUSTOM_VAL_3
};
// 1. Call trackSessionStart when Play is clicked or if autoplay is used,
// i.e., when there's an intent to start playback.
this._mediaHeartbeat.trackSessionStart(mediaInfo, mediaMetadata);
......
......
// Chapter
var chapterMetadata = {
CUSTOM_KEY_1 : CUSTOM_VAL_1
};
var chapterDataInfo =
MediaHeartbeat.createChapterObject(CHAPTER_NAME,
CHAPTER_POSITION,
CHAPTER_LENGTH,
CHAPTER_START_TIME);
// 2. Track the MediaHeartbeat.Event.ChapterStart event when the chapter
// starts to play.
this._mediaHeartbeat.trackEvent(MediaHeartbeat.Event.ChapterStart,
chapterDataInfo,
chapterMetadata);
.......
.......
// 3. Call trackPlay() when the playback actually starts, i.e., when the first
// frame of the main content is rendered on the screen.
this._mediaHeartbeat.trackPlay();
.......
.......
// 4. Track the MediaHeartbeat.Event.ChapterComplete event when the chapter
// finishes playing.
this._mediaHeartbeat.trackEvent(MediaHeartbeat.Event.ChapterComplete);
.......
.......
// 5. Call trackComplete() when the playback reaches the end, i.e., when playback
// completes and finishes playing.
this._mediaHeartbeat.trackComplete();
........
........
// 6. Call trackSessionEnd() when the playback session is over. This method must be
// called even if the user does not watch the media to completion.
this._mediaHeartbeat.trackSessionEnd();
........
........
Código de muestra: capítulo al principio sample-code-chapter-at-the-beginning
En esta situación, el contenido de VOD se reproduce con un capítulo al principio de la reproducción.
Android
Para ver este caso en Android, configure el siguiente código:
// Set up mediaObject
MediaObject mediaInfo = MediaHeartbeat.createMediaObject(
Configuration.MEDIA_NAME,
Configuration.MEDIA_ID,
Configuration.MEDIA_LENGTH,
MediaHeartbeat.StreamType.VOD
);
HashMap<String, String> mediaMetadata = new HashMap<String, String>();
mediaMetadata.put(CUSTOM_KEY_1, CUSTOM_VAL_1);
mediaMetadata.put(CUSTOM_KEY_2, CUSTOM_VAL_2);
// 1. Call trackSessionStart() when the user clicks Play or if autoplay is used,
// i.e., there is an intent to start playback.
_mediaHeartbeat.trackSessionStart(mediaInfo, mediaMetadata);
......
......
// 2. Call trackPlay() when the playback actually starts, i.e., first frame of the
// main content is rendered on the screen.
_mediaHeartbeat.trackPlay();
.......
.......
// Chapter
HashMap<String, String> chapterMetadata = new HashMap<String, String>();
chapterMetadata.put(CUSTOM_KEY_1, CUSTOM_VAL_1);
MediaObject chapterDataInfo =
MediaHeartbeat.createChapterObject(CHAPTER_NAME,
CHAPTER_POSITION,
CHAPTER_LENGTH,
CHAPTER_START_TIME);
// 3. Track the MediaHeartbeat.Event.ChapterStart event when the chapter starts to play.
_mediaHeartbeat.trackEvent(MediaHeartbeat.Event.ChapterStart, chapterDataInfo, chapterMetadata);
.......
.......
// 4. Track the MediaHeartbeat.Event.ChapterComplete event when the chapter finishes playing.
_mediaHeartbeat.trackEvent(MediaHeartbeat.Event.ChapterComplete, null, null);
.......
.......
// 5. Call trackComplete() when the playback reaches the end, i.e., when the media completes
// and finishes playing.
_mediaHeartbeat.trackComplete();
........
........
// 6. Call trackSessionEnd() when the playback session is over. This method must be called even
// if the user does not watch the media to completion.
_mediaHeartbeat.trackSessionEnd();
........
........
iOS
Para ver este caso en iOS, configure el siguiente código:
when the user clicks Play
ADBMediaObject *mediaObject =
[ADBMediaHeartbeat createMediaObjectWithName:MEDIA_NAME
length:MEDIA_LENGTH
streamType:ADBMediaHeartbeatStreamTypeVOD];
NSMutableDictionary *mediaContextData = [[NSMutableDictionary alloc] init];
[mediaContextData setObject:CUSTOM_VAL_1 forKey:CUSTOM_KEY_1];
[mediaContextData setObject:CUSTOM_VAL_2 forKey:CUSTOM_KEY_2];
// 1. Call trackSessionStart when the user clicks Play or if autoplay is used,
// i.e., there is an intent to start playback.
[_mediaHeartbeat trackSessionStart:mediaObject data:mediaContextData];
.......
.......
// Chapter
NSMutableDictionary *chapterContextData = [[NSMutableDictionary alloc] init];
[chapterContextData setObject:CONTEXT_DATA_VALUE forKey:CONTEXT_DATA_KEY];
id chapterInfo =
[ADBMediaHeartbeat createChapterObjectWithName:CHAPTER_NAME
position:CHAPTER_POSITION
length:CHAPTER_LENGTH
startTime:CHAPTER_START_TIME];
// 2. Call ADBMediaHeartbeatEventChapterStart when the chapter starts.
[_mediaHeartbeat trackEvent:ADBMediaHeartbeatEventChapterStart
mediaObject:chapterInfo
data:chapterContextData];
.......
.......
// 3. Call trackPlay when the playback actually starts, i.e., when the
// first frame of the main content is rendered on the screen.
[_mediaHeartbeat trackPlay];
.......
.......
// 4. Call ADBMediaHeartbeatEventChapterComplete when the chapter starts.
[_mediaHeartbeat trackEvent:ADBMediaHeartbeatEventChapterComplete
mediaObject:nil
data:nil];
.......
.......
// 5. Call trackComplete when the playback reaches the end, i.e., when the
// media completes and finishes playing.
[_mediaHeartbeat trackComplete];
.......
.......
// 6. Call trackSessionEnd when the playback session is over. This method
// must be called even if the user does not watch the media to completion.
[_mediaHeartbeat trackSessionEnd];
.......
.......
JavaScript
Para ver esta situación en JavaScript, escriba el siguiente texto:
// Set up mediaObject
var mediaInfo = MediaHeartbeat.createMediaObject(
Configuration.MEDIA_NAME,
Configuration.MEDIA_ID,
Configuration.MEDIA_LENGTH,
MediaHeartbeat.StreamType.VOD
);
var mediaMetadata = {
CUSTOM_KEY_1 : CUSTOM_VAL_1,
CUSTOM_KEY_2 : CUSTOM_VAL_2,
CUSTOM_KEY_3 : CUSTOM_VAL_3
};
// 1. Call trackSessionStart() when Play is clicked or if autoplay is used,
// i.e., when there's an intent to start playback.
this._mediaHeartbeat.trackSessionStart(mediaInfo, mediaMetadata);
......
......
// Chapter
var chapterMetadata = {
CUSTOM_KEY_1 : CUSTOM_VAL_1
};
var chapterDataInfo =
MediaHeartbeat.createChapterObject(CHAPTER_NAME,
CHAPTER_POSITION,
CHAPTER_LENGTH,
CHAPTER_START_TIME);
// 2. Track the MediaHeartbeat.Event.ChapterStart event when the chapter starts to play.
this._mediaHeartbeat.trackEvent(MediaHeartbeat.Event.ChapterStart,
chapterDataInfo,
chapterMetadata);
.......
.......
// 3. Call trackPlay() when the playback actually starts, i.e., when the first
// frame of the main content is rendered on the screen.
this._mediaHeartbeat.trackPlay();
.......
.......
// 4. Track the MediaHeartbeat.Event.ChapterComplete event when the chapter
// finishes playing.
this._mediaHeartbeat.trackEvent(MediaHeartbeat.Event.ChapterComplete);
.......
.......
// 5. Call trackComplete() when the playback reaches the end, i.e., when playback
// completes and finishes playing.
this._mediaHeartbeat.trackComplete();
........
........
// 6. Call trackSessionEnd() when the playback session is over. This method must be
// called even if the user does not watch the media to completion.
this._mediaHeartbeat.trackSessionEnd();
........
........