mirror of
https://github.com/element-hq/element-web
synced 2024-11-27 19:56:47 +03:00
Use createObjectURL instead of readAsDataURL for videos
This commit is contained in:
parent
60e55594dd
commit
ceaa3aaca4
1 changed files with 9 additions and 17 deletions
|
@ -148,29 +148,21 @@ function infoForImageFile(matrixClient, roomId, imageFile) {
|
||||||
* @return {Promise} A promise that resolves with the video image element.
|
* @return {Promise} A promise that resolves with the video image element.
|
||||||
*/
|
*/
|
||||||
function loadVideoElement(videoFile) {
|
function loadVideoElement(videoFile) {
|
||||||
const deferred = Promise.defer();
|
|
||||||
|
|
||||||
// Load the file into an html element
|
// Load the file into an html element
|
||||||
const video = document.createElement("video");
|
const video = document.createElement("video");
|
||||||
|
|
||||||
const reader = new FileReader();
|
|
||||||
reader.onload = function(e) {
|
|
||||||
video.src = e.target.result;
|
|
||||||
|
|
||||||
// Once ready, returns its size
|
// Once ready, returns its size
|
||||||
// Wait until we have enough data to thumbnail the first frame.
|
// Wait until we have enough data to thumbnail the first frame.
|
||||||
video.onloadeddata = function() {
|
video.onloadeddata = function() {
|
||||||
|
URL.revokeObjectURL(video.src);
|
||||||
deferred.resolve(video);
|
deferred.resolve(video);
|
||||||
};
|
};
|
||||||
video.onerror = function(e) {
|
video.onerror = function(e) {
|
||||||
deferred.reject(e);
|
deferred.reject(e);
|
||||||
};
|
};
|
||||||
};
|
|
||||||
reader.onerror = function(e) {
|
|
||||||
deferred.reject(e);
|
|
||||||
};
|
|
||||||
reader.readAsDataURL(videoFile);
|
|
||||||
|
|
||||||
|
// We don't use readAsDataURL because massive files and b64 don't mix.
|
||||||
|
video.src = URL.createObjectURL(videoFile);
|
||||||
return deferred.promise;
|
return deferred.promise;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue