Track chapters and segments on Chromecast track-chapters-and-segments-on-chromecast

The following instructions provide guidance for implementation using 2.x SDKs.

IMPORTANT
If you are implementing a 1.x version of the SDK, you can download the Developers Guide here: Download SDKs.
  1. Identify when the chapter start event occurs and create the ChapterObject instance by using the chapter information.

    ChapterObject chapter tracking reference:

    note note
    NOTE
    These variables are only required if you are planning to track chapters.
    table 0-row-3 1-row-3 2-row-3 3-row-3 4-row-3 3-align-center 7-align-center 11-align-center 15-align-center 19-align-center
    Variable Name Description Required
    name Chapter name Yes
    position Chapter position Yes
    length Chapter length Yes
    startTime Chapter start time Yes

    Chapter object: createChapterObject

    code language-js
    chapterInfo = ADBMobile.media.createChapterObject("First Chapter", 1, CHAPTER1_LENGTH, CHAPTER1_START_POS);
    
  2. If you include custom metadata for the chapter, create the context data variables for the metadata:

    code language-js
    var chapterContextData = {
        segmentType: "Sample segment type"
    };
    
  3. To begin tracking the chapter playback, track the ChapterStart event: trackEvent

    code language-js
    ADBMobile.media.trackEvent(ADBMobile.media.Event.ChapterStart, ChapterInfo, chapterContextData);
    
  4. When playback reaches the chapter end boundary, as defined by your custom code, call the ChapterComplete event in the MediaHeartbeat instance: trackEvent

    code language-js
    ADBMobile.media.trackEvent(ADBMobile.media.Event.ChapterComplete);
    
  5. If chapter playback did not complete because the user chose to skip the chapter (for example, if the user seeks out of the chapter boundary), track the ChapterSkip event: trackEvent

    code language-js
    ADBMobile.media.trackEvent(ADBMobile.media.Event.ChapterSkip);
    
  6. If there are any additional chapters, repeat steps 1 through 5.

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