作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
在 dash.js 中,文件 DashMetrics.js 上有一个函数 getBandwidthForRepresentation()。它需要两个参数:representationId 和 periodId。我可以使用 getCurrentRepresentationSwitch() 来获取 representationId。但我不知道如何获取 periodId?用什么函数可以获取数据?
我试图在 dash-reference-client 上查看示例,它令人困惑并且仍然不知道。
谢谢
最佳答案
我知道你的问题有点老了,你可能不再需要这个了,但我会发送一些代码以防有人最终需要它。
如您所述,getBandwidthForRepresentation()
需要 2 个参数:representationId
和 periodId
如何获取representationId:
var metrics = player.getMetricsFor('video')
var dashMetrics = player.getDashMetrics()
var representationId = dashMetrics.getCurrentRepresentationSwitch(metrics).to
如何获取peropdId:
var streamInfo = player.getActiveStream().getStreamInfo()
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/
在 dash.js 中,文件 DashMetrics.js 上有一个函数 getBandwidthForRepresentation()。它需要两个参数:representationId 和 peri
我是一名优秀的程序员,十分优秀!