已略過章節的 VOD 播放 vod-playback-with-a-skipped-chapter

情境 scenario

此情境中,使用者會在主要內容中略過某個章節。

這是與單一章節 VOD 播放相同的情境,只是此情境中的使用者要超出章節範圍搜尋,因此略過該章節,直接進入主要內容。

觸發
心率方法
網路呼叫
附註
使用者點按​ 「播放」
trackSessionStart
Analytics 內容開始、心率內容開始
Measurement Library 不知道有前段廣告。這些網路呼叫仍完全等同於iOS🔗案例中沒有岔斷的播放。
章節開始。
trackEvent:ChapterStart
心率章節開始
播放章節的第一個時間格。
trackPlay
心率章節播放
當章節內容在主要內容之前播放,我們想在章節開始時啟動心率。
章節播放。
章節心率
搜尋會開始略過第一個章節。
trackEvent:trackSeekStart
搜尋期間沒有心率
搜尋已完成。
trackEvent:trackSeekComplete
心率會在此之後繼續。
應用程式發現使用者的搜尋已超出正常章節範圍。
trackEvent:trackChapterSkip
內容播放。
內容心率
內容已完成播放。
trackComplete
心率內容完成
此網路呼叫完全等同於 iOS 中沒有岔斷的播放情境。
工作階段已結束。
trackSessionEnd
SessionEnd 表示檢視工作階段的結尾。即使使用者未持續觀看到媒體完成,仍必須呼叫此 API。

參數 parameters

除了沒有章節完成網路呼叫以外,章節播放期間使用的參數完全等同於 具有一個章節的 VOD 播放 情境中的參數。

程式碼範例 sample-code

Android

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

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

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

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

// 2. Track the MediaHeartbeat.Event.ChapterStart event when the chapter starts to play.
_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.
_mediaHeartbeat.trackPlay();

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

// 4. Track the MediaHeartbeat.Event.SeekStart event when the user begins to seek out
//    of the chapter with the intent to skip it.
_mediaHeartbeat.trackEvent(MediaHeartbeat.Event.SeekStart, null, null);

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

// 5. Track the MediaHeartbeat.Event.SeekComplete event when the user seeks out of the
//    chapter with the intent to skip it.
_mediaHeartbeat.trackEvent(MediaHeartbeat.Event.SeekComplete, null, null);

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

// 6. Track the MediaHeartbeat.Event.ChapterSkip event because the user skipped the
//    chapter by seeking out of it in the steps above.
_mediaHeartbeat.trackEvent(MediaHeartbeat.Event.ChapterSkip, null, null);

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

// 7. Call trackComplete() when the playback reaches the end, i.e., when the media
//    completes and finishes playing.
_mediaHeartbeat.trackComplete();

........

........

// 8. 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

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

// Set up mediaObject
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's 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. Track the ADBMediaHeartbeatEventChapterStart event 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. Track the trackEvent:ADBMediaHeartbeatEventSeekStart event when the user
//    begins to seek out of the chapter with the intent to skip it.
[_mediaHeartbeat trackEvent:ADBMediaHeartbeatEventSeekStart mediaObject:nil data:nil];
.......
.......

// 5. Track the trackEvent:ADBMediaHeartbeatEventSeekComplete event when the
//    user seeks out of the chapter with the intent to skip it.
[_mediaHeartbeat trackEvent:ADBMediaHeartbeatEventSeekComplete mediaObject:nil data:nil];
.......
.......

// 6. Track the trackEvent:ADBMediaHeartbeatEventChapterSkip event because the
//    user skipped the chapter by seeking out of it in the steps above.
[_mediaHeartbeat trackEvent:ADBMediaHeartbeatEventChapterSkip
               mediaObject:chapterInfo
               data:chapterContextData];
.......
.......

// 7. Call trackComplete when the playback reaches the end, i.e., when the media
//    completes and finishes playing.
[_mediaHeartbeat trackComplete];
.......
.......

// 8. 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

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

// 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., 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.SeekStart event when the user begins
//    to seek out of the chapter with the intent to skip it.
this._mediaHeartbeat.trackEvent(MediaHeartbeat.Event.SeekStart);

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

// 5. Track the MediaHeartbeat.Event.SeekComplete event when the user seeks
//    out of the chapter with the intent to skip it.
this._mediaHeartbeat.trackEvent(MediaHeartbeat.Event.SeekComplete);

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

// 6. Track the MediaHeartbeat.Event.ChapterSkip event because the user
//    skipped the chapter by seeking out of it in the steps above.
this._mediaHeartbeat.trackEvent(MediaHeartbeat.Event.ChapterSkip);

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

// 7. Call trackComplete() when the playback reaches the end, i.e., completes
//    and finishes playing.
this._mediaHeartbeat.trackComplete();

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

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

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