Javascript 如何在DashMetrics上获取periodId

Javascript 如何在DashMetrics上获取periodId,javascript,dash.js,Javascript,Dash.js,在dash.js文件DashMetrics.js中有一个函数getBandwidthForRepresentation()。它需要两个参数:representationId和periodId。我可以使用getCurrentRepresentationSwitch()获取representationId。但我不知道如何获取周期ID?使用哪个函数可以获取数据 我试着在dash参考客户机上查看示例,它令人困惑,仍然不知道 谢谢我知道你的问题有点老了,你可能不再需要这个了,但我会发送一些代码,以防最终有

在dash.js文件DashMetrics.js中有一个函数getBandwidthForRepresentation()。它需要两个参数:representationId和periodId。我可以使用getCurrentRepresentationSwitch()获取representationId。但我不知道如何获取周期ID?使用哪个函数可以获取数据

我试着在dash参考客户机上查看示例,它令人困惑,仍然不知道


谢谢

我知道你的问题有点老了,你可能不再需要这个了,但我会发送一些代码,以防最终有人需要它

如您所述,
getBandwidthForRepresentation()
需要两个参数:
representationId
periodId

如何获得表示ID

  • 您需要获取指标:
    var metrics=player.getMetricsFor('video')
  • 和dashMetrics:
    var dashMetrics=player.getDashMetrics()
  • 现在我们得到representationId:
    var representationId=dashMetrics.getCurrentRepresentationSwitch(metrics).to
如何获得peropid

  • 我们获得活动流信息:
    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)
希望能有帮助