【问题标题】:How can I make a full width videojs v5 progress bar?如何制作全宽 videojs v5 进度条?
【发布时间】:2015-10-20 11:09:00
【问题描述】:

我想更改 videojs v5 控件布局,以便在 vjs-control-bar 区域顶部制作全宽进度条,类似于 v5 之前的播放器皮肤。

这是 v5 皮肤:

这是 v5 之前的皮肤。注意全宽进度条:

我应该如何进行?是否有必要修改ProgressControl 组件中的component structure tree 或者仅使用CSS 来完成现有的ProgressControl 组件?

我注意到我可以通过将 vjs-progress-control display CSS 属性从 flex 更改为 blockinitialinline 将其置于顶部,但我无法将宽度设置为 100% (其他 ProgressControl 组件宽度仍在考虑中)。我认为这是因为vjs-progress-control 仍在容器的弹性流中。


编辑

我取得了一些进展。我可以通过使用以下 CSS 来达到预期的效果:

.vjs-progress-control {  
  position: absolute;
  bottom: 26px; /* The height of the ControlBar minus 4px. */
  left: 0;
  right: 0;
  width: 100%;
  height: 10px; /* the height must be reduced from 30 to 10px in order to allow the buttons below (e.g. play) to be pushed */
}
.vjs-progress-holder {/* needed to have a real 100% width display. */
  margin-left: 0px;
  margin-right: 0px;
}

除非你们中的某个人找到一种方法让它变得更好,否则我会在允许时将此编辑作为已接受的答案发布。

【问题讨论】:

  • 我更喜欢你的解决方案而不是公认的答案——代码更少,而且效果很好。其余的真的只是绒毛。
  • 您的班级名称前缺少.
  • @tmm1 我的错!我刚刚修好了。

标签: css video.js


【解决方案1】:

DEMO

  .vjs-fluid {
    overflow: hidden;
  }
  .vjs-control-bar {
    display: block;
  }
  .vjs-control {
    position: absolute;
  }
  .vjs-progress-control {
    bottom: 28px; left: 0;
    height: 10px;
    width:  100%;
  }
  .vjs-progress-holder  {
    position: absolute;
    left: 0; margin: 0;
    height: 8px; width:  100%;
  }
  .vjs-play-progress,
  .vjs-load-progress {
    height: 8px;
  }
  .vjs-play-progress:before {
    font-size: 12px; top: -2px; 
    text-shadow: 0 0 2px black 
  }
  .vjs-current-time {
    display: block;
    left: 35px;
  }
  .vjs-time-divider {
    position: absolute;
    display: block;
    left: 70px;
  }
  .vjs-remaining-time {
    display: none;   
  }
  .vjs-duration {
    display: block;
    left: 70px;
  }
  .vjs-volume-menu-button {
    position: absolute;
    bottom: 0; right: 55px;
  }
  .vjs-playback-rate {
    position: absolute;
    bottom: 0; right: 28px;
  }
  .vjs-fullscreen-control {
    position: absolute;
    bottom: 0; right: 0;
  }

仍然需要设置字幕、标题和章节按钮的样式

【讨论】:

  • 这在 Chrome 之外不起作用。其他浏览器在控制栏和进度条之间显示重叠。 OP的解决方案也是如此。我不知道重叠的解决方案是什么,但我想我会提到它。不过,对您的回答 +1。
【解决方案2】:
.video-js .vjs-progress-control {
    position:absolute;
    width: 100%;
    top:-.3em;
    height:3px;
    /* deal with resulting gap between progress control and control bar that
       is the result of the attempt to keep things "clickable" on the controls */
    background-color: #2B333F;
    background-color: rgba(43, 51, 63, 0.7);
}

.video-js .vjs-progress-holder {
    position:absolute;
    margin:0px;
    top:0%;
    width:100%;
}

这似乎解决了我在其他浏览器中使用从 video.js 继承的 :hover 样式时遇到的问题。更熟练的css 开发人员可能能够使扩展成为自下而上的扩展,从而无需围绕进度控件和颜色的位置进行花哨的步法。

【讨论】:

    【解决方案3】:

    这是一个最小的自定义皮肤(在 scss 中),它在其余控件上方显示一个全宽进度条。这适用于 video.js 5.19.2

    .video-js.vjs-custom-skin {
      .vjs-custom-control-spacer {
        display: flex;
        flex: 1 1 auto;
      }
      .vjs-time-divider {
        display: inherit;
      }
      .vjs-current-time {
        margin-left: 1em;
      }
      .vjs-current-time, .vjs-duration {
        display: inherit;
        padding: 0;
      }
      .vjs-remaining-time {
        display: none;
      }
      .vjs-play-progress:before {
        display: none;
      }
      .vjs-progress-control {
        position: absolute;
        left: 0;
        right: 0;
        width: 100%;
        height: .5em;
        top: -.5em;
    
        &:hover {
          height: 1.5em;
          top: -1.5em;
        }
      }
      .vjs-progress-holder {
        margin: 0;
        height: 100%;
      }
    }
    

    【讨论】:

      猜你喜欢
      • 2017-05-18
      • 1970-01-01
      • 1970-01-01
      • 2011-04-26
      • 1970-01-01
      • 1970-01-01
      • 2016-10-13
      • 1970-01-01
      • 2013-03-28
      相关资源
      最近更新 更多