use seconds
This commit is contained in:
parent
0742c28cfa
commit
77e123d2d9
4 changed files with 18 additions and 24 deletions
|
@ -49,14 +49,14 @@ Ox.load({
|
|||
}
|
||||
//Ctrl - Seek Back
|
||||
if (e.keyCode == 17) {
|
||||
var seekTime = parseInt(parseFloat($('#seekTime').val()) * 1000);
|
||||
var seekTime = parseFloat($('#seekTime').val());
|
||||
var currTime = Video.get();
|
||||
var newTime = currTime - seekTime;
|
||||
Video.set(newTime);
|
||||
}
|
||||
//Alt - Seek Fwd.
|
||||
if (e.keyCode == 18) {
|
||||
var seekTime = parseInt(parseFloat($('#seekTime').val()) * 1000);
|
||||
var seekTime = parseFloat($('#seekTime').val());
|
||||
var currTime = Video.get();
|
||||
var newTime = currTime + seekTime;
|
||||
Video.set(newTime);
|
||||
|
|
|
@ -144,7 +144,7 @@ TextArea.prototype.fromSrt = function(txt) {
|
|||
} else {
|
||||
out += "\n";
|
||||
}
|
||||
} else if (parseInt(sp.tcOutMs) < parseInt(Video.player.duration * 1000)) {
|
||||
} else if (parseInt(sp.tcOutMs) < Video.player.duration) {
|
||||
out += "\n" + ms2npt(sp.tcOutMs) + "\n\n";
|
||||
}
|
||||
}
|
||||
|
@ -186,7 +186,7 @@ function spansToSrt(arr, fmt, start_no) {
|
|||
linebreaksRegex = new RegExp('\n+', "g")
|
||||
text = text.replace(linebreaksRegex, "\n");
|
||||
if (!s.tcOutMs) {
|
||||
s.tcOutMs = parseInt(Video.player.duration * 1000);
|
||||
s.tcOutMs = Video.player.duration;
|
||||
}
|
||||
if (fmt == 'srt') {
|
||||
srt += srtNo + " ";
|
||||
|
@ -322,13 +322,13 @@ SeekBar.prototype.init = function() {
|
|||
//gets current time-code (int) of seekbar position
|
||||
SeekBar.prototype.get = function() {
|
||||
var cssPos = parseInt(this.pointerElem.css("left"));
|
||||
var pos = parseInt((cssPos / this.width) * (Video.player.duration * 1000));
|
||||
var pos = parseInt((cssPos / this.width) * Video.player.duration);
|
||||
return pos;
|
||||
}
|
||||
|
||||
//sets seek bar css pos according to current time-code
|
||||
SeekBar.prototype.set = function(ms) {
|
||||
var cssPos = parseInt(((ms / 1000) / Video.player.duration) * this.width);
|
||||
SeekBar.prototype.set = function(seconds) {
|
||||
var cssPos = parseInt((seconds / Video.player.duration) * this.width);
|
||||
this.elem.css("left", cssPos + "px");
|
||||
}
|
||||
|
||||
|
@ -432,7 +432,7 @@ function loadCuts(url, id) {
|
|||
pandora_api('get', {id: id, keys: ['cuts']}, function(result) {
|
||||
var txt = '';
|
||||
result.data.cuts.forEach(function(cut) {
|
||||
textArea.insertTc(ms2npt(cut*1000));
|
||||
textArea.insertTc(ms2npt(cut));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
10
js/player.js
10
js/player.js
|
@ -80,13 +80,13 @@ VideoPlayer.prototype.set = function(pos) {
|
|||
this.player.setAttribute('src', url);
|
||||
//this.player.setAttribute('autoplay', autoplay);
|
||||
element.replaceWith(this.player); */
|
||||
this.player.currentTime = pos / 1000;
|
||||
this.player.currentTime = pos;
|
||||
}
|
||||
|
||||
|
||||
VideoPlayer.prototype.get = function() {
|
||||
try {
|
||||
return parseInt(this.player.currentTime * 1000);
|
||||
return this.player.currentTime;
|
||||
} catch(err) { }
|
||||
return -1;
|
||||
}
|
||||
|
@ -120,10 +120,10 @@ VideoPlayer.prototype.togglePause = function() {
|
|||
}
|
||||
|
||||
VideoPlayer.prototype.listener = function() {
|
||||
var ms = Video.get();
|
||||
var npt = ms2npt(ms);
|
||||
var t = Video.get();
|
||||
var npt = ms2npt(t);
|
||||
$('#timeCode').html(npt);
|
||||
var seekBarPos = parseInt((ms / (Video.duration * 1000)) * 320);
|
||||
var seekBarPos = parseInt((t/Video.duration) * 320);
|
||||
$('#seekPointer').css("left", seekBarPos + "px");
|
||||
}
|
||||
|
||||
|
|
|
@ -2,12 +2,14 @@ function npt2ms(npt) {
|
|||
var ms = 0.0
|
||||
npt = String(npt);
|
||||
var p = npt.split(':')
|
||||
for(i=0;i<p.length;i++)
|
||||
for(i=0;i<p.length;i++) {
|
||||
ms = ms * 60 + parseFloat(p[i])
|
||||
return ms * 1000;
|
||||
}
|
||||
return ms;
|
||||
}
|
||||
|
||||
function ms2npt(ms) {
|
||||
function ms2npt(seconds) {
|
||||
var ms = seconds * 1000;
|
||||
var it, ss, mm, hh, npt;
|
||||
var it = parseInt(ms / 1000)
|
||||
ms = ms - it * 1000;
|
||||
|
@ -45,14 +47,6 @@ function ms2time(ms) {
|
|||
return npt.substr(npt.length-9, npt.length-6);
|
||||
}
|
||||
|
||||
function framesToNpt(timeCode) {
|
||||
var frames = timeCode.substring(9, 11);
|
||||
var ms = parseInt(frames) / 25 * 1000;
|
||||
var ms = String(ms);
|
||||
var ms = strpad(ms, '0', 3, 'right');
|
||||
var timeCodeNpt = timeCode.substring(0,8) + "." + ms;
|
||||
return timeCodeNpt;
|
||||
}
|
||||
|
||||
function strpad(str, pad, len, dir) {
|
||||
while (str.length < len) {
|
||||
|
|
Loading…
Reference in a new issue