0

I want to control dash.js-2.6.1 video player remotely so that I could make it play the video at a specific bitrate from the bitrate list it catches from (*.mpd) manifest file. It's obvious that this can be done using the bitrate checkbox of the player located on control bar of the player's window, but I want to do this in the background, remotely and several times during video playback. In other words, I want to find out which function in the source code of the player catches the bitrate value chosen by the user on the checkbox and feed that function manually and remotely.

I will appreciate anyone who guides me how to reach my goal even through another method.

Maher
  • 11
  • 3

1 Answers1

0

Look at the MediaPlayer.js source:

The function you want to look at is 'setQualityFor':

/**
     * Sets the current quality for media type instead of letting the ABR Heuristics automatically selecting it.
     * This value will be overwritten by the ABR rules unless setAutoSwitchQualityFor(type, false) is called.
     *
     * @param {string} type - 'video' or 'audio'
     * @param {number} value - the quality index, 0 corresponding to the lowest bitrate
     * @memberof module:MediaPlayer
     * @see {@link module:MediaPlayer#setAutoSwitchQualityFor setAutoSwitchQualityFor()}
     * @see {@link module:MediaPlayer#getQualityFor getQualityFor()}
     * @instance
     */
    function setQualityFor(type, value) {
        if (!playbackInitialized) {
            throw PLAYBACK_NOT_INITIALIZED_ERROR;
        }
        abrController.setPlaybackQuality(type, streamController.getActiveStreamInfo(), value);
    }
Mick
  • 24,231
  • 1
  • 54
  • 120
  • Thank's Dear Mick – Maher Oct 20 '17 at 22:08
  • Would you please instruct me how to use this function? I added these two lines<< player.setAutoSwitchQuality(false); player.setQualityFor("video", 0); >> aiming to make player to play with least bitrate but nothing happened! – Maher Oct 22 '17 at 19:21
  • The a look at onFragmentLoadProgress in AbrController.js. This calls setPlaybackQuality which cals changeQuality which then calls setQualityFor. This should give you a feel for the use and the parameters etc. – Mick Oct 22 '17 at 21:43