我知道你的問題是慈祥的老人和你可能不需要這個了,但我會送一些代碼的情況下,有人需要它最終。
正如你所說,getBandwidthForRepresentation()
預計2個參數:representationId
和periodId
如何獲得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)
希望它可以幫助