首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >为播放器设置选项

为播放器设置选项
EN

Stack Overflow用户
提问于 2017-11-08 18:36:09
回答 1查看 274关注 0票数 0

我正在使用HTML5视频播放器,使用以下代码

代码语言:javascript
复制
<video id="my-video" class="video-js" controls preload="auto" width="100%"  height="600"
   data-setup="{}">
    <source src="" type='video/mp4'>
    <source src="" type='video/webm'>
    <p class="vjs-no-js">
      To view this video please enable JavaScript, and consider upgrading to a web browser that
      <a href="http://videojs.com/html5-video-support/" target="_blank">supports HTML5 video</a>
    </p>
  </video>

有没有办法添加设置选项的播放器像播放较小版本的hd,我正在编码的视频到不同的速度。或者有一些免费的播放器提供这样的功能,

EN

回答 1

Stack Overflow用户

发布于 2017-11-10 22:34:30

听起来您使用的是具有多个可用视频比特率的ABR流。

ABR (自适应比特率流)本质上允许客户端设备或播放器以块(例如10秒块)下载视频,并从最适合当前网络条件的比特率中选择下一个块。在这个答案中也可以看到更多信息:https://stackoverflow.com/a/42365034/334402

大多数常见的开源DASH或HLS (ABR格式)播放器都包含选择所需曲目的机制。

例如,在dash.js player中,查看MediaPlayer.js源代码:

和函数'setQualityFor':

代码语言:javascript
复制
/**
     * 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);
    }
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/47177429

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档