I am using videojs in my react project. Currently the time of player looks like this 0:00/0:10 . I want a time format of HH:MM:SS:FF (00:00:00:00) where F is frame. I am not able to find any solution. Is there any way I can do it?
I'm unfamiliar with the format 0:00/0:10
, but you can use the following function to convert time (in seconds) to HH:MM:SS:FF
format :
var convertTime = function (input, fps) {
var pad = function(input) {return (input < 10) ? "0" + input : input;};
fps = (typeof fps !== 'undefined' ? fps : 24 );
return [
pad(Math.floor(input / 3600)),
pad(Math.floor(input % 3600 / 60)),
pad(Math.floor(input % 60)),
pad(Math.floor(input * fps % fps))
].join(':');
}
var convertTime = function (input, fps) {
var pad = function(input) {return (input < 10) ? "0" + input : input;};
fps = (typeof fps !== 'undefined' ? fps : 24 );
return [
pad(Math.floor(input / 3600)),
pad(Math.floor(input % 3600 / 60)),
pad(Math.floor(input % 60)),
pad(Math.floor(input * fps % fps))
].join(':');
}
document.body.innerHTML = '<pre>' + JSON.stringify({
5.4416555 : convertTime(5.4416555),
126.2344452 : convertTime(126.2344452),
1156.1535548 : convertTime(1156.1535548),
9178.1351559 : convertTime(9178.1351559),
13555.3515135 : convertTime(13555.3515135)
}, null, '\t') + '</pre>';
See also this Fiddle.