Billybobbonnet
Billybobbonnet

Reputation: 3226

How can I make a full width videojs v5 progress bar?

I would like to change the videojs v5 controls layout in order to make a full width progress bar, on top of the vjs-control-bar area, similar to the pre-v5 player skin.

Here is the v5 skin: enter image description here

And here is the pre-v5 skin. Notice the full width progress bar: enter image description here

How should I proceed? Is it necessary to modify the component structure tree within the ProgressControl component or can it be done using CSS only, with the existing ProgressControl component?

I noticed that I can put it on top by changing the vjs-progress-control display CSS property from flex to block, initial or inline but I can't set the width to 100% (other ProgressControl components width are still considered). I assume it is because the vjs-progress-control is still in the flex flow of the container.


EDIT

I made some progress. I can achieve the desired effect by using the following 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;
}

Unless one of you find a way to make it better, I will post this edit as accepted answer when it will be allowed.

Upvotes: 8

Views: 8512

Answers (3)

tmm1
tmm1

Reputation: 2115

Here is a minimal custom skin (in scss) that shows a full-width progress bar above the rest of the controls. This works with 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%;
  }
}

Upvotes: 0

Thomas
Thomas

Reputation: 6690

.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%;
}

This seemed to get rid of the problems I had across other browsers with the :hover styling inherited from video.js. More masterful css developers might be able to make the expansion a bottom-to-top expansion, negating the need for the fancy footwork around the position of the progress control and the color.

Upvotes: 4

rafaelcastrocouto
rafaelcastrocouto

Reputation: 12161

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;
  }

There's still need to style the subtitles, captions and chapter buttons

Upvotes: 6

Related Questions