gpt4 book ai didi

javascript - 如何在 DashMetrics 上获取 periodId

转载 作者:行者123 更新时间:2023-11-29 21:32:42 26 4
gpt4 key购买 nike

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

我试图在 dash-reference-client 上查看示例,它令人困惑并且仍然不知道。

谢谢

最佳答案

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

如您所述,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)

希望对你有帮助

关于javascript - 如何在 DashMetrics 上获取 periodId,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35753308/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com