Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
Merge pull request #2176 from matrix-org/hs/object-urls-video
Browse files Browse the repository at this point in the history
Use createObjectURL instead of readAsDataURL for videos
  • Loading branch information
dbkr authored Oct 4, 2018
2 parents c4d39ee + 259063e commit a7beb0b
Showing 1 changed file with 8 additions and 15 deletions.
23 changes: 8 additions & 15 deletions src/ContentMessages.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,24 +153,17 @@ function loadVideoElement(videoFile) {
// Load the file into an html element
const video = document.createElement("video");

const reader = new FileReader();
reader.onload = function(e) {
video.src = e.target.result;

// Once ready, returns its size
// Wait until we have enough data to thumbnail the first frame.
video.onloadeddata = function() {
deferred.resolve(video);
};
video.onerror = function(e) {
deferred.reject(e);
};
// Wait until we have enough data to thumbnail the first frame.
video.onloadeddata = function() {
URL.revokeObjectURL(video.src);
deferred.resolve(video);
};
reader.onerror = function(e) {
video.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;
}

Expand Down

0 comments on commit a7beb0b

Please sign in to comment.