|
|
@ -19,29 +19,44 @@ evanEnv.enableAutoDownload = true;
|
|
|
|
|
|
|
|
|
|
|
|
(function () {
|
|
|
|
(function () {
|
|
|
|
evanEnv.videos = document.getElementsByTagName('video');
|
|
|
|
evanEnv.videos = document.getElementsByTagName('video');
|
|
|
|
evanEnv.buildArrayBuffer = function (bufferList) {
|
|
|
|
evanEnv.downloadRawData = function (bufferList, fileName = 'out', ext = '.mp4') {
|
|
|
|
|
|
|
|
var buffList = new Array();
|
|
|
|
var totalLength = 0;
|
|
|
|
var totalLength = 0;
|
|
|
|
|
|
|
|
|
|
|
|
for (var i = 0; i < bufferList.length; i++) {
|
|
|
|
for (var i = 0; i < bufferList.length; i++) {
|
|
|
|
totalLength += bufferList[i].byteLength;
|
|
|
|
totalLength += bufferList[i].byteLength;
|
|
|
|
|
|
|
|
if (totalLength > 1073741824 || i == bufferList.length - 1) {
|
|
|
|
|
|
|
|
buffList.push(new Uint8Array(totalLength));
|
|
|
|
|
|
|
|
totalLength = 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
var tmp = new Uint8Array(totalLength);
|
|
|
|
|
|
|
|
var lastLength = 0;
|
|
|
|
var lastLength = 0;
|
|
|
|
|
|
|
|
var part = 0;
|
|
|
|
for (var ix = 0; ix < bufferList.length; ix++) {
|
|
|
|
for (var ix = 0; ix < bufferList.length; ix++) {
|
|
|
|
tmp.set(new Uint8Array(bufferList[ix]), lastLength);
|
|
|
|
//10485760
|
|
|
|
|
|
|
|
//1073741824
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
buffList[part].set(new Uint8Array(bufferList[ix]), lastLength);
|
|
|
|
lastLength += bufferList[ix].byteLength;
|
|
|
|
lastLength += bufferList[ix].byteLength;
|
|
|
|
|
|
|
|
if (lastLength > 1073741824) {
|
|
|
|
|
|
|
|
part++;
|
|
|
|
|
|
|
|
lastLength = 0
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return tmp.buffer;
|
|
|
|
|
|
|
|
};
|
|
|
|
for (var iz = 0; iz < buffList.length; iz++) {
|
|
|
|
evanEnv.downloadRawData = function (bufferList, fileName = 'out.mp4') {
|
|
|
|
var buff = buffList[iz];
|
|
|
|
var buff = evanEnv.buildArrayBuffer(bufferList);
|
|
|
|
let url = window.URL.createObjectURL(new Blob([buff], { type: "arraybuffer" }))
|
|
|
|
let url = window.URL.createObjectURL(new Blob([buff], {type: "arraybuffer"}))
|
|
|
|
const link = document.createElement('a');
|
|
|
|
const link = document.createElement('a');
|
|
|
|
link.style.display = 'none';
|
|
|
|
link.style.display = 'none';
|
|
|
|
link.href = url;
|
|
|
|
link.href = url;
|
|
|
|
link.setAttribute('download', fileName + "_" + iz + ext);
|
|
|
|
link.setAttribute('download', fileName);
|
|
|
|
document.body.appendChild(link);
|
|
|
|
document.body.appendChild(link);
|
|
|
|
link.click();
|
|
|
|
link.click();
|
|
|
|
document.body.removeChild(link);
|
|
|
|
document.body.removeChild(link);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
evanEnv.download = function () {
|
|
|
|
evanEnv.download = function () {
|
|
|
@ -49,7 +64,7 @@ evanEnv.enableAutoDownload = true;
|
|
|
|
var currentItem = evanEnv.mediaSources[i];
|
|
|
|
var currentItem = evanEnv.mediaSources[i];
|
|
|
|
if (currentItem.downloaded == undefined || currentItem.downloaded == false) {
|
|
|
|
if (currentItem.downloaded == undefined || currentItem.downloaded == false) {
|
|
|
|
for (var x = 0; x < currentItem.rawSources.length; x++) {
|
|
|
|
for (var x = 0; x < currentItem.rawSources.length; x++) {
|
|
|
|
evanEnv.downloadRawData(currentItem.rawSources[x], 'mediasource_' + i + '_' + x + '.mp4');
|
|
|
|
evanEnv.downloadRawData(currentItem.rawSources[x], 'mediasource_' + i + '_' + x);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
currentItem.downloaded = true;
|
|
|
|
currentItem.downloaded = true;
|
|
|
@ -57,7 +72,7 @@ evanEnv.enableAutoDownload = true;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
evanEnv.downloadMediaSource = function (mediaSource) {
|
|
|
|
evanEnv.downloadMediaSource = function (mediaSource) {
|
|
|
|
for (var x = 0; x < mediaSource.rawSources.length; x++) {
|
|
|
|
for (var x = 0; x < mediaSource.rawSources.length; x++) {
|
|
|
|
evanEnv.downloadRawData(mediaSource.rawSources[x], 'mediasource_' + x + '.mp4');
|
|
|
|
evanEnv.downloadRawData(mediaSource.rawSources[x], 'mediasource_' + x);
|
|
|
|
mediaSource.downloaded = true;
|
|
|
|
mediaSource.downloaded = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|