2016-03-02 40 views
1

在dash.js文件DashMetrics.js上有一個函數getBandwidthForRepresentation()。它需要兩個參數:representationId和periodId。我可以使用getCurrentRepresentationSwitch()來獲取representationId。但我不知道如何獲得periodId?我可以使用哪些功能獲取數據?如何在DashMetrics上獲取periodId

我試圖看到在短跑參考客戶端上的示例,它是混亂,仍然不知道。

感謝

回答

0

我知道你的問題是慈祥的老人和你可能不需要這個了,但我會送一些代碼的情況下,有人需要它最終。

正如你所說,getBandwidthForRepresentation()預計2個參數:representationIdperiodId

如何獲得representationId

  • 你需要得到指標:var metrics = player.getMetricsFor('video')
  • 和dashMetrics:var dashMetrics = player.getDashMetrics()
  • 現在我們得到representationId:var representationId = dashMetrics.getCurrentRepresentationSwitch(metrics).to

如何獲得peropdId

  • 我們得到的活動流信息:var streamInfo = player.getActiveStream().getStreamInfo()
  • 我們使用指數作爲periodId:var periodId = streamInfo.index

如何獲得帶寬

  • 我們現在可以得到的帶寬:var bandwidth = dashMetrics.getBandwidthForRepresentation(representationId, periodId)

全碼:

var metrics = player.getMetricsFor('video') 
var dashMetrics = player.getDashMetrics() 
var representationId = dashMetrics.getCurrentRepresentationSwitch(metrics).to 
var streamInfo = player.getActiveStream().getStreamInfo() 
var periodId = streamInfo.index 
var bandwidth = dashMetrics.getBandwidthForRepresentation(representationId, periodId) 

希望它可以幫助