Last active
March 22, 2018 16:08
-
-
Save Bubblesphere/fd9e806277c3bb777b74245d98abb8b5 to your computer and use it in GitHub Desktop.
Hijacking the current time, total time & mouse over seek bar time with an offset for a non-live streamed source
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var hijackSeekBarTime = Clappr.UICorePlugin.extend({ | |
name: 'hijack_seekbar_media_control', | |
bindEvents: function () { | |
this.listenTo(this.core.mediaControl, Clappr.Events.MEDIACONTROL_MOUSEMOVE_SEEKBAR, this.updateTime); | |
}, | |
updateTime: function () { | |
// check out seek_time.js in order to understand how the offset is calculated | |
// https://github.com/clappr/clappr/blob/f1db5431225425d483639290fedc8a7c624e6c64/src/plugins/seek_time/seek_time.js | |
$("[data-seek-time]").html("0:00"); | |
} | |
}) | |
var hijackCurrentAndTotalTime = Clappr.UIContainerPlugin.extend({ | |
name: 'hijack_seekbar', | |
bindEvents: function () { | |
this.listenTo(this.container.playback, Clappr.Events.PLAYBACK_TIMEUPDATE, this.updateTime); | |
}, | |
updateTime: function (current, total) { | |
var originalTimeOffset = new Date("2018-01-01 05:30:00"); | |
var newTime = new Date(originalTimeOffset); | |
var newTimeTotal = new Date(originalTimeOffset); | |
newTime.setTime(originalTimeOffset.getTime() + Math.floor(current) * 1000); | |
newTimeTotal.setTime(originalTimeOffset.getTime() + Math.floor(total) * 1000); | |
$("[data-position]").html(newTime.toTimeString().split(' ')[0]); | |
$("[data-duration]").html(newTimeTotal.toTimeString().split(' ')[0]); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment