2
(function(){
  var url = "http://dash.edgesuite.net/envivio/Envivio-dash2/manifest.mpd";
  var player = dashjs.MediaPlayer().create();
  player.initialize(document.querySelector("#videoPlayer"), url, 
})();

var bitrates = player.getBitrateInfoListFor("video");
console.log('My bitrate:' + bitrates.length);

In console write

My bitrate:0

how can I find out what quality the video has and how to change it?

Can I play a mpd file without dash.js using Media Source and xhr ?

Jesse
  • 3,522
  • 6
  • 25
  • 40
Justin Rec
  • 21
  • 1
  • 4

2 Answers2

3

how can I find out what quality the video has and how to change it?

You need to wait until the manifest has been loaded and the player has initialized completely, which happens asynchronously. Add an event listener like so:

player.on("streamInitialized", function () {
    var bitrates = player.getBitrateInfoListFor("video");
    console.log('My bitrate:' + bitrates.length);
});

Now you should get a list of the bitrates available.

To change the quality manually, use http://cdn.dashjs.org/latest/jsdoc/module-MediaPlayer.html#setQualityFor__anchor

Can I play a mpd file without dash.js using Media Source and xhr ?

Sure, but you can't just pass a manifest to MSE so you would still need do all the hard stuff a DASH player does such as parsing the manifest, determining the media URLs, selecting the relevant quality etc.

Anonymous Coward
  • 1,096
  • 11
  • 22
0

For those who are coming in future, the code

player.setQualityFor('video', {number});
will change the quality, but however due to auto bitrate quality switch, the quality returns to the quality the bandwidth can afford. To set quality manually and switch off auto bitrate,
  let settingsp = player.getSettings();
  settingsp.streaming.abr.autoSwitchBitrate = false;

Now you can use setQualityFor() anchor to change quality and it remains same throughout the video.

Zincfan
  • 739
  • 5
  • 7