-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUtils.js
103 lines (87 loc) · 3.14 KB
/
Utils.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
/************************************************************************************************
Kioo Media Player: A Player With Clear Crystal Sound, Extra Sharp Video, with a Beautiful Design.
Copyright (C) 2017 - 2020 Kioo Media Player <[email protected]>.
Homepage: https://www.kiooplayer.com
Developer: Godfrey E Laswai <[email protected]>
All rights reserved.
Use of this source code is governed by a BSD-3-Clause license that can be
found in the BSD-LICENSE file or see it here <https://opensource.org/licenses/BSD-3-Clause>.
*************************************************************************************************/
function milliSecToString(msec) {
msec = Math.floor(msec/1000)
var ss = msec%60
msec = (msec-ss)/60
var mm = msec%60
var hh = (msec-mm)/60
if (ss < 10)
ss = "0" + ss
if (mm < 10)
mm = "0" + mm
if (hh < 10)
hh = "0" + hh
return hh + ":" + mm +":" + ss
}
function clean() {
// var path = kioo.source;
path=path.replace(/^(file:\/{3})|(qrc:\/{2})|(http:\/{2})/,"");
cleanPath = decodeURIComponent(path);
console.log(cleanPath);
}
function fileName(path) {
path = path.toString()
return path.substring(path.lastIndexOf("/") + 1)
}
function getFile(path) {
var k,subs
for (var i = 1; i < path.length; ++i) {
k = "file:"+path[i].toString(); //qml use url and will add qrc: if no scheme
k = k.replace(/\\/g, "/");
if (k.endsWith(".srt") || k.endsWith(".ass") || k.endsWith(".ssa") || k.endsWith(".sub")
|| k.endsWith(".idx") || k.endsWith(".mpl2") || k.endsWith(".smi") || k.endsWith(".sami")
|| k.endsWith(".sup") || k.endsWith(".txt"))
subs = k
else {
pModel.append({ fTitle: Utils.fileName(k), fLink: k})
pList.currentIndex = pModel.count-1;
if(i==1)
changeSource(k)
}
}
if (subs) {
subtitle.autoLoad = true
subtitle.file = subs
} else {
subtitle.file = ""
}
}
function getSingleFile(path) {
var k;
k = "file:"+path.toString(); //qml use url and will add qrc: if no scheme
k = k.replace(/\\/g, "/");
if (k.endsWith(".srt") || k.endsWith(".ass") || k.endsWith(".ssa") || k.endsWith(".sub")
|| k.endsWith(".idx") || k.endsWith(".mpl2") || k.endsWith(".smi") || k.endsWith(".sami")
|| k.endsWith(".sup") || k.endsWith(".txt")) {
subtitle.fuzzyMatch = true;
subtitle.autoLoad = true;
}
else {
if(!(fileName(k).length <= 6)) {
pModel.append({ fTitle: fileName(k), fLink: k});
pList.currentIndex = pModel.count - 1;
subtitle.file = ""
}
}
}
function scale(x) {
return x*screen.devicePixelRatio
}
function request(url, callback) {
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = (function(myxhr) {
return function() {
callback(myxhr);
}
})(xhr);
xhr.open('GET', url, true);
xhr.send('');
}