forked from 0x2620/pandora
queue multiple cache requests
This commit is contained in:
parent
c0615911d2
commit
71b77f6359
1 changed files with 35 additions and 24 deletions
|
@ -6,6 +6,7 @@ pandora.fs = (function() {
|
|||
downloads: {},
|
||||
enabled: false,
|
||||
},
|
||||
queue = [],
|
||||
requestedBytes = 100*1024*1024*1024; // 100GB
|
||||
|
||||
if(window.webkitRequestFileSystem) {
|
||||
|
@ -40,6 +41,12 @@ pandora.fs = (function() {
|
|||
resolution: pandora.user.ui.videoResolution,
|
||||
size: 0
|
||||
};
|
||||
|
||||
queue.length
|
||||
? queue.push([id, callback])
|
||||
: startDownload(id, callback);
|
||||
|
||||
function startDownload(id, callback) {
|
||||
pandora.api.get({id: id, keys: ['parts']}, function(result) {
|
||||
var parts = result.data.parts, sizes = [];
|
||||
downloadPart(0);
|
||||
|
@ -58,6 +65,9 @@ pandora.fs = (function() {
|
|||
if (result.url) {
|
||||
if (part + 1 == parts) {
|
||||
delete that.downloads[id];
|
||||
if (queue.length) {
|
||||
startDownload.apply(null, queue.shift());
|
||||
}
|
||||
} else {
|
||||
downloadPart(part + 1);
|
||||
}
|
||||
|
@ -66,6 +76,7 @@ pandora.fs = (function() {
|
|||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
that.removeVideo = function(id, callback) {
|
||||
|
|
Loading…
Reference in a new issue