4

I'm building a video player in node.js with nw.js. It will run offline.

One of the features I'd like to incorporate on this application is the possibility of to play the video dragging and drop it into a "box".

The restriction I'm facing on this implementation is the necessity of encode the video in order to play it, using, for example, the function readAsDataURL(). As discussed in this post, it is not possible to get the fullpath of a file.

"Upload" the entire video, for me, doesn't make sense as long it is already stored in the user's hd.

If he/she try to play The Big Bang Theory (about 20 minutes), it won't be problem to wait 2 or 3 minutes, differently of try to watch The Lord of Rings.

Is there good workaround to deal with this problem?

I appreciate any help.

UPDATE:

I was thinking about the copy and paste of file in a field, as long as with this action is possible to get its URL. But it is not the best thing in terms of user experience...

Community
  • 1
  • 1

1 Answers1

0

I've managed. I've changed readAsDataURL() for createObjectURL().

For the sake of 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 The Lord of Rings marathon of my users is saved.