streaming - VideoJS如何增加缓冲区大小?

我正在尝试使用 VideoJS 播放 HLS。基本上流本身工作正常,但似乎缓冲区大小很小,视频每隔几秒/分钟滞后 1-2 秒。有没有办法增加预加载的段的实际大小?目前我已经像这样实现了 VideoJS:

...
        <div class="container-fluid">
            <div class="row">
                <div class="player-center">
                    <video-js autoplay id=player class="vjs-fluid" controls="true">
                        <source src="{{ playlist_url }}" type="application/x-mpegURL">
                    </video-js>
                    <script src="{% static 'videojs_old/video.js' %}"></script>
                    <script src="{% static 'videojs_old/videojs-http-streaming.js' %}"></script>
                    <script>
                        videojs.Vhs.xhr.beforeRequest = function(options) {
                        options.headers = options.headers || {};
                        options.headers.Authorization = "{{ access_token }}";

                        console.log('options', options)
                        return options;
                        };
                        var player = videojs('player',
                            {fill: false},
                            {autoplay: true},
                            {responsive: true},
                            {fluid: true},
                            {GOAL_BUFFER_LENGTH: 100},
                            {CMAX_GOAL_BUFFER_LENGTH: 150},
                            {preload: "auto"});
                        player.play();
                    </script>
                </div>
            </div>
        </div>

但似乎 GOAL_BUFFER_LENGTH 和 CMAX_GOAL_BUFFER_LENGTH 有任何效果。

回答1

常量不是玩家级别的选项。您也只能传递一个选项对象。

videojs.Vhs.GOAL_BUFFER_LENGTH = 100;
videojs.Vhs.MAX_GOAL_BUFFER_LENGTH = 150;
var player = videojs('player', {
  fill: false,
  autoplay: true,
  responsive: true,
  fluid: true,
  preload: "auto"
});

相似文章