Search code examples
video.js

How to change the current time in the progress control?


Is it possible to manualy set the current time position on the timeline? I need this because I have several separated videos which represent one video and are playing in different players.

For example, the actual current time is marked as white dot, the desired current time that I want to show as red dot.

Can I do this somehow without creating completely new custom controlbar?


Solution

  • Middleware could be part of the solution, which allows you to intercept and modify what's sent to / received from the playback tech (video element).

    var myMiddleware = function(player) {
      return {
        currentTime: function(ct) {
          // When the video el says the currentTime is 60s, report 160s
          return ct + 100;
        },
        setCurrentTime: function(time) {
          // When the user / progress bar wants to seek to 220s, actually seek to 120s
          return time - 100; 
        }
      };
    };
    
    videojs.use('*', myMiddleware);