Search code examples
javascriptcssvideo.js

How to change the position of videojs Control bar elements order


I am using the video.js player for my website. I want to change the position of control bar elements.

Presently, it shows play/pause, volume, progress bar and full screen.

How can I able to change order?

I have my code below:

var videojs = videojs('video-player', {
    techOrder:  ["youtube", "html5"],
    preload: 'auto',
    controls: true,
    autoplay: true,
    fluid: true,
    controlBar: {
        CurrentTimeDisplay: true,
        TimeDivider: true,
        DurationDisplay: true
    },
    plugins: {
        videoJsResolutionSwitcher: {
            default: 'high',
            dynamicLabel: true
        }
    }
}).ready(function() {
    var player = this;
   ......

Solution

  • I could able resolve by making changes as below:

        var videojs = videojs('video-player', {
        techOrder:  ["youtube", "html5"],
        preload: 'auto',
        controls: video.player.controls,
        autoplay: video.player.autoplay,
        fluid: true,
        controlBar: {
            children: [
                "playToggle",
                "volumeMenuButton",
                "durationDisplay",
                "timeDivider",
                "currentTimeDisplay",
                "progressControl",
                "remainingTimeDisplay",
                "fullscreenToggle"
            ]
        },
        plugins: {
            videoJsResolutionSwitcher: {
                default: 'high',
                dynamicLabel: true
            }
        }
    }).ready(function() {
        var player = this;
    

    I thought it will help somebody in future.

    Taken idea from JS Bin