您可以取得與目前由TVSDK播放之選取項目相關之時間軸的說明。 當應用程式顯示自訂拖曳列控制項時,最有用的方式是識別與廣告內容對應的內容區段。
以下是如下螢幕擷取畫面中所示的範例實作。
使用get
方法訪問MediaPlayer
中的Timeline
對象。
Timeline
類封裝了與MediaPlayer
實例當前載入的媒體項相關聯的時間軸內容相關的資訊。 Timeline
類提供對基礎時間軸的只讀視圖的訪問。 Timeline
類提供了獲取所有已放置TimelineMarker
對象的getter方法。
重複TimelineMarkers
清單,並使用傳回的資訊來實作時間軸。
「TimelineMarker」物件包含兩項資訊:
// access the timeline object
var timeline:Timeline = mediaPlayer.timeline;
// iterate through the list of TimelineMarkers
var markers:Vector.<TimelineMarker> = timeline.timelineMarkers;
markers.forEach(function(item:TimelineMarker,
index:int,
vector:Vector.<TimelineMarker>):void {
// the start position of the marker
var startPos:Number = item.time;
// the duration of the marker
var duration:Number = item.duration;
// draw the marker on the scrub-bar
}