dragermrb / capacitor-plugin-video-editor

Capacitor plugin to edit videos
12 stars 8 forks source link

No Result With MediaFileResult #20

Closed prometeomcclellan closed 6 months ago

prometeomcclellan commented 9 months ago

Hello. I'm trying to compress videos to low their size and be able to upload them to my server. I have installed and followed the documentation of yours. The thing is that when my code gets to the point of MediaFileResult it just goes out of the function and I just can not get the result.

So basically here is my code.

Imagen 22-1-24 a las 5 01 p  m

prometeomcclellan commented 9 months ago

`$("#fileInputV").on("change", evt => { evt.preventDefault(); evt.stopPropagation(); evt.stopImmediatePropagation(); const fileInputVs = (document.getElementById("fileInputV") as HTMLInputElement).files; console.dir(fileInputVs); this.isVideo = true;

  setTimeout(() => {
    if (fileInputVs.length > 0) {
      this.videosSeleccionados = fileInputVs.length;
      $("#imagenesConteo").fadeIn('xslow');
      $("#buttonSubmitVideo").fadeIn('xslow');

      for (let index = 0; index < fileInputVs.length; index++) {
        this.fechaFirma = new Date().toISOString();
        const file = fileInputVs[index];
        var path = (window.URL || window.webkitURL).createObjectURL(file);
        console.log('path', path);

        VideoEditor.edit({
          path: path.substring(12),
          transcode: {
            width: 720,
            height: 480,
            keepAspectRatio: true,
          },
          trim: {
            startsAt: 3 * 1000, // from 00:03
            endsAt: 10 * 1000, // to 00:10
          },
        }).then(
          (mediaFileResult: MediaFileResult) => {
        //    progressListener.remove();
        alert(parseInt(localStorage.getItem('idAtencion')))
            this.videos.push(mediaFileResult.file);
            this.videoArray = {
              IdAtencion: parseInt(localStorage.getItem('idAtencion')),
              VideoData: mediaFileResult.file
            }

            console.log('El comprimido ');
            console.dir(this.videoArray)

            console.log('mediaPath', mediaFileResult.file.path);
          },
          (error) => {
            console.error('error', error);
          }
        );

        if (index == (fileInputVs.length-1)) {
          this.isLoading = false
        }

      }

    }else{
    }
  }, this.randomIntFromInterval(1, 5));
});

}`

dragermrb commented 9 months ago

Hi @prometeomcclellan

Could you attach the logcat (android) output?

Also add the line console.log('mediaFileResult', mediaFileResult) just before the alert(...) and show the output as well.

prometeomcclellan commented 9 months ago

Sure thing. And now I realize it's a matter of it seems not to work on Web but on devices only. Am I right? Sorry to bother. Let me give a try and test in a mobile device.

Imagen 23-1-24 a las 9 40 a  m

And this is the Android Studio Log about this issue.

E0B5881E-2FA6-405C-9993-D1396E203C2E

dragermrb commented 9 months ago

The path field must be a local path. It can optionally starts with file://, but in the previous example you use a blob:http and it is not valid.

prometeomcclellan commented 9 months ago

Ok. I tried that on Web the path.substring(11); Let me give it a hit on mobile and I'll let you know. Thanks for your time.

merbin2012 commented 8 months ago

Hi Do you have any suggestion for converting to local path Currently I can generate the following URLs

http://localhost/_capacitor_content_/com.android.providers.media.documents/document/video%3A1000123897
Or
content://com.android.providers.media.documents/document/video%3A1000123897
dragermrb commented 8 months ago

Hi!

Results from plugin capacitor-plugin-file-picker (https://github.com/dragermrb/capacitor-plugin-file-picker) are valid as path for capacitor-plugin-video-editor

martinbertinat commented 4 months ago

Hi @dragermrb ! Do you plan to release a new version of the file picker plugin with Capacitor 6 support? Thanks 🫶

dragermrb commented 4 months ago

@martinbertinat

https://github.com/dragermrb/capacitor-plugin-file-picker/releases/tag/v6.0.1