function npt2ms(npt) {
var ms = 0.0
npt = String(npt);
var p = npt.split(':')
for(i=0;i
3) {
ms = ms.toString().substring(0,3);
}
ss = it % 60;
mm = ((it - ss) / 60) % 60;
hh = ((it - (mm * 60) - ss) / 3600) % 60;
npt = hh+':'+strpad(mm.toString(), '0', 2, 'left')
npt += ':'+strpad(ss.toString(), '0', 2, 'left')
npt += '.'+strpad(ms.toString(), '0', 3, 'left')
return npt;
}
function ms2frames(ms, fmt) {
if (!fmt) var fmt = "PAL";
var npt = ms2npt(ms);
var dotpos = npt.lastIndexOf(".");
var mmStr = npt.substring(dotpos + 1, npt.length);
var mmInt = parseInt(mmStr);
if (fmt == 'PAL') {
var frames = parseInt((mmInt / 1000) * 24);
} else if (fmt == "NTSC") {
var frames = parseInt((mmInt / 1000) * 29.97);
}
var framesTc = '';
var joinToken = ":";
var framesTc = npt.substring(0, dotpos ) + joinToken + frames;
return framesTc;
}
function ms2time(ms) {
var npt = ms2npt(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) {
if (dir == 'left')
str = pad + str;
else if (dir == 'right')
str = str + pad;
}
return str;
}
function isValidTimecode(tc) {
var tc = $.trim(tc);
var nptRegex = new RegExp("^[0-9][0-9]?\:[0-9][0-9]\:[0-9][0-9][\.|\,|\:][0-9]?[0-9]?[0-9]?$");
return nptRegex.test(tc);to
}
//where filters is a JSON object, for eg. {'Video Files': '*.dv;*.ogg;*.ogv;*.ogx;*.avi;*.mov;*.mp4;*.mpeg;*.mpg;*.vob'}
function selectFile(filters, callback) {
alert('select file');
//fixme. select file
callback && callback(fp);
}
function getFileNameExt(filename) {
var dotPos = filename.lastIndexOf(".");
var ext = filename.substring(dotPos + 1, filename.length);
return ext;
}
function getFileNameSansExt(filename) {
var dotPos = filename.lastIndexOf(".");
if (dotPos != '-1') {
var filenameSansExt = filename.substring(0,dotPos);
} else {
var filenameSansExt = filename;
}
return filenameSansExt;
}