-
Notifications
You must be signed in to change notification settings - Fork 0
/
cordova-file.js
70 lines (52 loc) · 1.67 KB
/
cordova-file.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
// var url = [
// "file:///storage/emulated/"
// ];
// fileExtenson = ".mp3 / .mp4 / Or Any Other File";
(function(window,undefined)
{
function getFiles(url,fileExtenson,success,fail)
{
var index = 0;
var addFileEntry = function (entry) {
var dirReader = entry.createReader();
dirReader.readEntries(
function (entries) {
var i=0;
while(i!=entries.length) {
if (entries[i].isDirectory === true) {
// Recursive -- call back into this subdirectory
addFileEntry(entries[i]);
} else {
if(entries[i].name.indexOf(fileExtenson) != -1 || entries[i].name.indexOf(fileExtenson) != -1)
{
var file = {};
file.name = entries[i].name;
file.nativeURL = entries[i].nativeURL;
file.fullPath = entries[i].fullPath;
musicList.push(file);
}
}
i+=1;
}
success(musicList);
},
function (error) {
fail(error);
});
};
var addError = function (error) {
fail(error);
};
var i=0;
while(i!=url.length)
{
if (url[i] === null || url[i].length === 0)
{
continue; // skip blank / non-existent paths for this platform
}
window.resolveLocalFileSystemURL(url[i], addFileEntry, addError);
i+=1;
}
}
window.getFiles = getFiles;
})(window);