有緩衝的 VOD 播放 vod-playback-with-buffering

情境 scenario

此情境中,播放 VOD 內容時發生一些緩衝。

除非另有指定,否則此情境中的網路呼叫與沒有廣告的 VOD 播放情境中的呼叫相同。

觸發
心率方法
網路呼叫
附註
使用者點按​ 「播放」
trackSessionStart
Analytics 內容開始、心率內容開始
可能是使用者點按​ 播放 ​或自動播放事件。
播放視訊的第一個時間格。
trackPlay
心率內容播放
此方法會觸發計時器。只要繼續播放,便會每 10 秒傳送心率。
內容播放。
內容心率
緩衝開始。
trackEvent:BufferStart
心率緩衝
內容已緩衝。
內容心率
緩衝完成。
trackEvent:BufferComplete
心率緩衝、心率播放
內容播放。
內容心率
內容已完成播放。
trackComplete
心率內容完成
已到播放點的結尾。
工作階段已結束。
trackSessionEnd
SessionEnd 表示檢視工作階段的結尾。即使使用者未觀看視訊到完成,也必須呼叫此 API。

參數 parameters

心率緩衝

參數
附註
s:event:type
"buffer"

程式碼範例 sample-code

此情境中,播放 VOD 內容時會發生緩衝。

Android

如要在 Android 中查看此情境,請設定下列程式碼:

// Set up mediaObject

MediaObject mediaInfo = MediaHeartbeat.createMediaObject(
  Configuration.MEDIA_NAME,
  Configuration.MEDIA_ID,
  Configuration.MEDIA_LENGTH,
  MediaHeartbeat.StreamType.VOD

);

HashMap<String, String> videoMetadata = new HashMap<String, String>();
videoMetadata.put(CUSTOM_KEY_1, CUSTOM_VAL_1);
videoMetadata.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, videoMetadata);

......
......

// 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();

.......
.......

// 3. Track the MediaHeartbeat.Event.BufferStart event when the video player
//    goes into the buffering state and begins to buffer content.
_mediaHeartbeat.trackEvent(MediaHeartbeat.Event.BufferStart, null, null);

.......
.......

// 4. Track the MediaHeartbeat.Event.BufferComplete event when the video player
//    goes into the buffering state and begins to buffer content.
_mediaHeartbeat.trackEvent(MediaHeartbeat.Event.BufferComplete, null, null);

.......
.......

// 5. Call trackComplete() when the playback reaches the end, i.e., when the
//    video 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 video to completion.
_mediaHeartbeat.trackSessionEnd();

........

iOS

如要在 iOS 中查看此情境,請設定下列程式碼:

// Set up mediaObject
ADBMediaObject *mediaObject =
[ADBMediaHeartbeat createMediaObjectWithName:MEDIA_NAME
                   length:MEDIA_LENGTH
                   streamType:ADBMediaHeartbeatStreamTypeVOD];

NSMutableDictionary *videoContextData = [[NSMutableDictionary alloc] init];
[videoContextData setObject:CUSTOM_VAL_1 forKey:CUSTOM_KEY_1];
[videoContextData 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:videoContextData];
.......
.......

// 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];
.......
.......

// 3. Track the trackEvent:ADBMediaHeartbeatEventBufferStart event when the
//    video player goes in buffering state and begins to buffer content.
[_mediaHeartbeat trackEvent:ADBMediaHeartbeatEventBufferStart
               mediaObject:nil
               data:nil];
.......
.......

// 4. Track the trackEvent:ADBMediaHeartbeatEventBufferComplete event when
//    the video player goes in buffering state and begins to buffer content.
[_mediaHeartbeat trackEvent:ADBMediaHeartbeatEventBufferComplete
               mediaObject:nil
               data:nil];
.......
.......

// 5. Call trackComplete when the playback reaches the end, i.e., when the
//    video 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 video to completion.
[_mediaHeartbeat trackSessionEnd];
.......
.......

JavaScript

若要檢視此情境,請輸入下列文字:

// Set up mediaObject

var mediaInfo = MediaHeartbeat.createMediaObject(
  Configuration.MEDIA_NAME,
  Configuration.MEDIA_ID,
  Configuration.MEDIA_LENGTH,
  MediaHeartbeat.StreamType.VOD

);

var videoMetadata = {
  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., there's an intent to start playback.
this._mediaHeartbeat.trackSessionStart(mediaInfo, videoMetadata);

......
......

// 2. Call trackPlay() when the playback actually starts, i.e., when the
//    first frame of the ad video is rendered on the screen.
this._mediaHeartbeat.trackPlay();

.......
.......

// 3. Track event MediaHeartbeat.Event.BufferStart when the video player
//    goes into the buffering state and begins to buffer content.
this._mediaHeartbeat.trackEvent(MediaHeartbeat.Event.BufferStart);

.......
.......

// 4. Track the MediaHeartbeat.Event.BufferComplete event when the
//    video player goes into the buffering state and begins to buffer content.
this._mediaHeartbeat.trackEvent(MediaHeartbeat.Event.BufferComplete);

.......
.......

// 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 video to completion.
this._mediaHeartbeat.trackSessionEnd();

........
........
recommendation-more-help
c8eee520-cef5-4f8c-a38a-d4952cfae4eb