Full path video using Node.js

I am creating a video player in node.js with nw.js. It will work offline.

One of the features that I would like to include in this application is the ability to play the video and drag it into the “drawer”.

The limitation that I encounter in this implementation is the need to encode the video to play it using, for example, a function readAsDataURL(). As discussed in this post, it is not possible to get the full path to the file.

"Download" all the video, for me, it makes no sense, because it is already saved in the user hd.

If he tries to play the Big Bang Theory (about 20 minutes), there will be no problem waiting 2 or 3 minutes, otherwise try watching The Lord of the Rings.

Is there a good way to solve this problem?

I appreciate any help.

UPDATE:

I was thinking of copying and pasting the file into the field, since with this action you can get its URL. But this is not the best thing from the point of view of the user ...

+4
source share
1 answer

I did it. I changed readAsDataURL()for createObjectURL().

For reference, my code

var video = document.createElement("video");
video.controls = true;
document.body.appendChild(video);
video.src = (window.URL||window.webkitURL).createObjectURL(file);
video.play();

Now the Lord of the Rings marathon is saved for my users.

0
source

Source: https://habr.com/ru/post/1607208/


All Articles