2016-03-02 1 views
1

Dans dash.js il y a une fonction getBandwidthForRepresentation() dans le fichier DashMetrics.js. Il a besoin de deux paramètres: representationId et periodId. Je peux utiliser getCurrentRepresentationSwitch() pour obtenir representationId. Mais je ne sais pas comment obtenir periodId? Avec quelle fonction puis-je obtenir les données?Comment obtenir periodId sur DashMetrics

J'ai essayé de voir l'exemple sur dash-reference-client, il est confus et toujours aucune idée.

Merci

Répondre

0

Je sais que votre question est un peu vieux et vous n'êtes probablement pas besoin de ce plus, mais je vais envoyer un code au cas où quelqu'un en a besoin par la suite.

Comme vous l'avez dit, getBandwidthForRepresentation() attend 2 paramètres: representationId et periodId

Comment arriver representationId:

  • dont vous avez besoin pour obtenir des mesures: var metrics = player.getMetricsFor('video')
  • et dashMetrics: var dashMetrics = player.getDashMetrics()
  • maintenant nous obtenons representationId: var representationId = dashMetrics.getCurrentRepresentationSwitch(metrics).to

Comment obtenir peropdId:

  • nous obtenons les informations de flux actif: var streamInfo = player.getActiveStream().getStreamInfo()
  • nous utilisons l'index comme periodId: var periodId = streamInfo.index

Comment obtenir bande passante:

  • nous pouvons maintenant obtenir la bande passante: var bandwidth = dashMetrics.getBandwidthForRepresentation(representationId, periodId)

complet Code:

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) 

Hope it helps