實作章節支援

您可透過下列方式,在以TVSDK為基礎的應用程式中定義及追蹤視訊追蹤章節:

  • 預設章節,由TVSDK內部管理。

    章節定義為每個廣告插播之間的時間。 例如,前段廣告插播和第一段中間廣告之間的時間定義為第一章。

  • 自訂章節,這些章節由應用程式管理,並以CMS資料或應用程式用來定義章節的其他方式為基礎。

    定義及追蹤預設或自訂章節。

    // First, enable chapter tracking by setting the boolean 'enableChapterTracking' to true: 
    
        vaTrackingMetadata.enableChapterTracking = YES; 
    
    // For custom chapter definitions, provide an array of chapters through the metadata:  
    // For example, 3 chapters of 60 second duration each: 
    
        NSMutableArray *chapters = [[[NSMutableArray alloc] init] autorelease]; 
    
        int chapterDuration = 60; 
        for (int i = 0; i < 3; i++) 
        { 
            PTVideoAnalyticsChapterData *chapterData =  
              [[[PTVideoAnalyticsChapterData alloc] init] autorelease]; 
            chapterData.name = [NSString stringWithFormat:@"chapter_%d", (i+1)]; 
            chapterData.range =  
              CMTimeRangeMake(CMTimeMakeWithSeconds(i * chapterDuration, 10000),  
              CMTimeMakeWithSeconds(chapterDuration, 10000)); 
    
            [chapters addObject:chapterData]; 
        } 
    
        vaTrackingMetadata.chapters = chapters; 
    
    // For default chapters, the application must not set custom chapters on the tracking metadata  
    // and simply enable chapters to be tracked by setting the boolean value as defined above.
    

本頁內容