How to enable the soundtrack during playback

I am loading content from the following manifest using dash.js into an HTML5 video: MPD file . It contains one video and four audio tracks. I am trying to understand how I can list and enable / disable various audio tracks.

I understand that if they were added as elements TRACKto the element VIDEO, I could enable / disable them through video.audioTracks, but this is not possible, since they are loaded from the manifest.

Any pointers on how I could solve this problem would be greatly appreciated.

+4
source share
2 answers
videoObject.audioTracks[audioTrackIndex].enabled = true;
+1
source

:

// assuming player is the instance of MediaPlayer
var metricsExt = player.getMetricsExt();
var num_qualities = metricsExt.getMaxIndexForBufferType('audio', 0 /*that the period index*/);
var qualities = [];
for (var i = 0; i < num_qualities; i++) {
     qualities.push(metricsExt.getBandwidthForRepresentation(i+1));
}

, :

player.setQualityFor('audio', newQualityIdx);
// newQualityIdx is the 0-based index of the chosen quality

, auto-switch-quality, :

player.setAutoSwitchQuality(false);
0

Source: https://habr.com/ru/post/1583741/


All Articles