From 77e123d2d98273e19adfdff7441a98c8d417e5dc Mon Sep 17 00:00:00 2001 From: j Date: Mon, 29 Feb 2016 15:06:39 +0530 Subject: [PATCH] use seconds --- js/app.js | 4 ++-- js/classes.js | 12 ++++++------ js/player.js | 10 +++++----- js/staticfuncs.js | 16 +++++----------- 4 files changed, 18 insertions(+), 24 deletions(-) diff --git a/js/app.js b/js/app.js index ac135be..a4948d1 100644 --- a/js/app.js +++ b/js/app.js @@ -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); diff --git a/js/classes.js b/js/classes.js index 53ad5ec..f163c37 100644 --- a/js/classes.js +++ b/js/classes.js @@ -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)); }); }); } diff --git a/js/player.js b/js/player.js index d8cdc18..330b40c 100644 --- a/js/player.js +++ b/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"); } diff --git a/js/staticfuncs.js b/js/staticfuncs.js index 63d4d53..2e3ac7d 100644 --- a/js/staticfuncs.js +++ b/js/staticfuncs.js @@ -2,12 +2,14 @@ function npt2ms(npt) { var ms = 0.0 npt = String(npt); var p = npt.split(':') - for(i=0;i