console
function makeRequest(method, url) {
return new Promise(function (resolve, reject) {
let xhr = new XMLHttpRequest();
xhr.responseType = 'arraybuffer';
xhr.open(method, url);
xhr.onload = function () {
if (this.status >= 200 && this.status < 300) {
resolve(xhr.response);
} else {
reject({
status: this.status,
statusText: xhr.statusText
});
}
};
xhr.onerror = function () {
reject({
status: this.status,
statusText: xhr.statusText
});
};
xhr.send();
});
}
function loadFromBuffer(file, buffer) {
return new Promise(function (resolve, reject) {
file.onError = function (e) {
reject(e);
};
file.onReady = function (info) {
resolve(info);
};
let tempBuffer = buffer;
tempBuffer.fileStart = 0;
if (!tempBuffer.fileStart) {
tempBuffer = buffer.slice(0);
tempBuffer.fileStart = 0;
}
file.appendBuffer(tempBuffer, true);
file.flush();
});
}
var videoUrl = "https://editor-engine.test.bhbapp.cn/videos/b.mp4";
async function start() {
let videoBuffer = await makeRequest("GET", videoUrl);
let videofile = MP4Box.createFile();
let videoInfo = await loadFromBuffer(videofile, videoBuffer);
}
start();
<html>
<head></head>
<body>
</body>
</html>