add option to select a local video file
This commit is contained in:
parent
1e0147d85b
commit
f642c010cd
2 changed files with 34 additions and 8 deletions
|
@ -123,6 +123,21 @@ pandora.ui.cacheDialog = function() {
|
||||||
})
|
})
|
||||||
.appendTo($item),
|
.appendTo($item),
|
||||||
|
|
||||||
|
$fileButton = Ox.FileButton({
|
||||||
|
title: 'Select Video...',
|
||||||
|
width: 128,
|
||||||
|
disabled: pandora.user.ui.section != 'items'
|
||||||
|
|| pandora.user.ui.item == ''
|
||||||
|
|| !!pandora.fs.getVideoURL(pandora.user.ui.item, pandora.user.ui.videoResolution, 1)
|
||||||
|
})
|
||||||
|
.css({
|
||||||
|
margin: '8px'
|
||||||
|
})
|
||||||
|
.bindEvent({
|
||||||
|
click: selectVideo
|
||||||
|
})
|
||||||
|
.appendTo($item),
|
||||||
|
|
||||||
$cacheListButton = Ox.Button({
|
$cacheListButton = Ox.Button({
|
||||||
title: 'Cache List...',
|
title: 'Cache List...',
|
||||||
width: 128,
|
width: 128,
|
||||||
|
@ -285,6 +300,17 @@ pandora.ui.cacheDialog = function() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function selectVideo(data) {
|
||||||
|
var blob = data.files[0],
|
||||||
|
name = pandora.fs.getVideoName(pandora.user.ui.item, pandora.user.ui.videoResolution, 1);
|
||||||
|
pandora.fs.storeBlob(blob, name, function() {
|
||||||
|
getCachedVideos(function(files) {
|
||||||
|
cachedVideos = Ox.api(files);
|
||||||
|
cachedVideos(data, callback);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function updateActiveDownloads() {
|
function updateActiveDownloads() {
|
||||||
pandora.fs.getVideos(function(files) {
|
pandora.fs.getVideos(function(files) {
|
||||||
files.forEach(function(file) {
|
files.forEach(function(file) {
|
||||||
|
|
|
@ -11,6 +11,7 @@ pandora.fs = (function() {
|
||||||
requestedBytes = 100*1024*1024*1024; // 100GB
|
requestedBytes = 100*1024*1024*1024; // 100GB
|
||||||
|
|
||||||
if(window.webkitRequestFileSystem) {
|
if(window.webkitRequestFileSystem) {
|
||||||
|
that.enabled = true;
|
||||||
window.webkitRequestFileSystem(window.PERSISTENT, requestedBytes, function(fs) {
|
window.webkitRequestFileSystem(window.PERSISTENT, requestedBytes, function(fs) {
|
||||||
that.fs = fs;
|
that.fs = fs;
|
||||||
that.fs.root.createReader().readEntries(function(results) {
|
that.fs.root.createReader().readEntries(function(results) {
|
||||||
|
@ -20,16 +21,11 @@ pandora.fs = (function() {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
that.enabled = true;
|
|
||||||
}, function(e) {
|
}, function(e) {
|
||||||
Ox.Log('FS', 'Error:', e);
|
Ox.Log('FS', 'Error:', e);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function getVideoName(id, resolution, part, track) {
|
|
||||||
return pandora.getVideoURLName(id, resolution, part, track).replace('/', '::');
|
|
||||||
}
|
|
||||||
|
|
||||||
function cacheVideo(id, callback) {
|
function cacheVideo(id, callback) {
|
||||||
active = true;
|
active = true;
|
||||||
pandora.api.get({id: id, keys: ['parts']}, function(result) {
|
pandora.api.get({id: id, keys: ['parts']}, function(result) {
|
||||||
|
@ -88,6 +84,10 @@ pandora.fs = (function() {
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
that.getVideoName = function(id, resolution, part, track) {
|
||||||
|
return pandora.getVideoURLName(id, resolution, part, track).replace('/', '::');
|
||||||
|
};
|
||||||
|
|
||||||
that.removeVideo = function(id, callback) {
|
that.removeVideo = function(id, callback) {
|
||||||
if (that.downloads && that.downloads[id] && that.downloads[id].cancel) {
|
if (that.downloads && that.downloads[id] && that.downloads[id].cancel) {
|
||||||
that.downloads[id].cancel();
|
that.downloads[id].cancel();
|
||||||
|
@ -101,7 +101,7 @@ pandora.fs = (function() {
|
||||||
var count = result.data.parts * pandora.site.video.resolutions.length, done = 0;
|
var count = result.data.parts * pandora.site.video.resolutions.length, done = 0;
|
||||||
Ox.range(result.data.parts).forEach(function(part) {
|
Ox.range(result.data.parts).forEach(function(part) {
|
||||||
pandora.site.video.resolutions.forEach(function(resolution) {
|
pandora.site.video.resolutions.forEach(function(resolution) {
|
||||||
var name = getVideoName(id, resolution, part + 1);
|
var name = that.getVideoName(id, resolution, part + 1);
|
||||||
that.fs.root.getFile(name, {create: false}, function(fileEntry) {
|
that.fs.root.getFile(name, {create: false}, function(fileEntry) {
|
||||||
// remove existing file
|
// remove existing file
|
||||||
fileEntry.remove(function(e) {
|
fileEntry.remove(function(e) {
|
||||||
|
@ -158,7 +158,7 @@ pandora.fs = (function() {
|
||||||
that.downloadVideoURL = function(id, resolution, part, track, callback) {
|
that.downloadVideoURL = function(id, resolution, part, track, callback) {
|
||||||
//fixme: would be nice to download videos from subdomains,
|
//fixme: would be nice to download videos from subdomains,
|
||||||
// currently throws a cross domain error
|
// currently throws a cross domain error
|
||||||
var name = getVideoName(id, resolution, part, track),
|
var name = that.getVideoName(id, resolution, part, track),
|
||||||
url = '/' + pandora.getVideoURLName(id, resolution, part, track),
|
url = '/' + pandora.getVideoURLName(id, resolution, part, track),
|
||||||
blobs = [], blobSize = 5*1024*1024, total;
|
blobs = [], blobSize = 5*1024*1024, total;
|
||||||
Ox.Log('FS', 'start downloading', url);
|
Ox.Log('FS', 'start downloading', url);
|
||||||
|
@ -253,7 +253,7 @@ pandora.fs = (function() {
|
||||||
};
|
};
|
||||||
|
|
||||||
that.getVideoURL = function(id, resolution, part, track) {
|
that.getVideoURL = function(id, resolution, part, track) {
|
||||||
var name = getVideoName(id, resolution, part, track);
|
var name = that.getVideoName(id, resolution, part, track);
|
||||||
return that.local[name];
|
return that.local[name];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue