From 2ac951bc6553bc6921f14ad92efc2d1b0a86b85d Mon Sep 17 00:00:00 2001 From: David Baker Date: Thu, 4 Oct 2018 20:46:09 +0100 Subject: [PATCH] Revert "Use createObjectURL instead of readAsDataURL for videos" --- src/ContentMessages.js | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/src/ContentMessages.js b/src/ContentMessages.js index a0bf75bccf..fd21977108 100644 --- a/src/ContentMessages.js +++ b/src/ContentMessages.js @@ -153,17 +153,24 @@ function loadVideoElement(videoFile) { // Load the file into an html element const video = document.createElement("video"); - // Wait until we have enough data to thumbnail the first frame. - video.onloadeddata = function() { - URL.revokeObjectURL(video.src); - deferred.resolve(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); + }; }; - video.onerror = function(e) { + reader.onerror = function(e) { deferred.reject(e); }; - - // We don't use readAsDataURL because massive files and b64 don't mix. - video.src = URL.createObjectURL(videoFile); + reader.readAsDataURL(videoFile); + return deferred.promise; }