mkv-player icon indicating copy to clipboard operation
mkv-player copied to clipboard

How would you add local files without the dropzone.

Open Ammar-AlDabbagh opened this issue 4 years ago • 2 comments

I spent ~7 hours trying to teach myself node.js and reactJS, so that I can have the website already contain the mkv without me dropping it in. The closest I got was

onDrop = (accept, reject) => {
    if (accept.length > 0) {

      let blob = fetch(process.env.PUBLIC_URL + 'videos/video1.mkv').then(res => {
        return res.blob();
      });
      let vid = new File([blob],"video1.mkv", {"type" : "video/x-matroska"},);
      const file = vid; 

so basically accept is useless. Just for that test I'd still drag but the file I drag in should have been useless, and video1 should have shown up instead. However, for some reason the preview= "blob:https/localhost/(link)" attribute is missing, and the size attribute is only 16 bytes, which is obviously wrong, but otherwise the File() seems to be created normally. This entire setup doesn't work as a few line of code later, in

for (let f of files) {
          if ((f.name.endsWith(".ass") || f.name.endsWith(".ssa")) && !subtitle)
            subtitle = URL.createObjectURL(new Blob([f.data]));
          else if (f.name.endsWith(".ttf"))
            fonts.push(URL.createObjectURL(new Blob([f.data])));
        }

A exception is raised because files is not irritable. I honestly don't even know what files refers to.

I have no idea what I'm doing, and looked up at least 30 not relevant guides which didn't help at all, and one which was relevant, but I have no idea how to implement it. I am accustomed to Django, if that helps in any way.

Ammar-AlDabbagh avatar Dec 02 '21 17:12 Ammar-AlDabbagh

UPDATE: Turns out ReactJS/webpack can't let me do that because of security issues or something.

Ammar-AlDabbagh avatar Dec 03 '21 08:12 Ammar-AlDabbagh

Why don't you just convert the video to mp4 and use generic HTML5 video?

meatflavourdev avatar Sep 16 '23 22:09 meatflavourdev