Currently, I have implemented this code in order to retrieve an image that has been "uploaded" into the browser using the <input type="file">
tag, and then sending the data to a component that will utilize it.
fileReady(e) {
let file: File = e[0];
let image = new Image();
let src: string;
image.onload = function () {
src = image.src;
//do something with image
}.bind(this);
src = URL.createObjectURL(file);
image.src = src;
}
While this method works perfectly for images, my next objective is to extend its capability to handle videos as well. Currently, neither the Video()
constructor nor the HTMLVideoElement
seem to achieve this goal. How can I adjust this code to accommodate videos?