如何设置dash.js-2.6.1视频播放器只播放特定比特率而不使用播放器控制栏上的相关复选框?

时间:2017-10-18 07:32:07

标签: javascript video playback adaptive-bitrate dash.js

我想远程控制dash.js-2.6.1 video player,以便我可以从它从(* .mpd)清单文件中捕获的比特率列表中以特定比特率播放视频。 很明显,这可以使用位于播放器窗口控制栏上的播放器的比特率复选框来完成,但我想在后台执行此操作, 在视频播放过程中远程和多次。 换句话说,我想找出source code of the player中哪个函数捕获用户在复选框上选择的比特率值,并手动和远程提供该函数。

我会感激任何指导我如何通过其他方法实现目标的人。

1 个答案:

答案 0 :(得分:0)

查看MediaPlayer.js来源:

您要查看的功能是'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);
    }
相关问题