You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by GitBox <gi...@apache.org> on 2019/09/25 13:26:48 UTC

[GitHub] [cordova-plugin-media-capture] edowney29 edited a comment on issue #135: Read the video file on android

edowney29 edited a comment on issue #135: Read the video file on android
URL: https://github.com/apache/cordova-plugin-media-capture/issues/135#issuecomment-503806273
 
 
   Make sure you are using `mediaFile.fullPath`, here is a working example below
   
   EDIT: Added capture method
   
   ```javascript
   videoCapture() {
     new Promise((resolve, reject) => {
       navigator.device.capture.captureVideo(
         function (mediaFiles) {
           resolve(mediaFiles[0]);
         },
         function (err) {
           reject(err);
         },
         {
           limit: 1,
           duration: 30
         }
       );
     })
       .then(mediaFile => {
         successVideo([mediaFile]);
       })
       .catch(err => {
         console.log(err);
       });
   }
   
   successVideo(mediaFiles) {
     let videoUrl = mediaFile.fullPath;
     if (this.isiOS) videoUrl = "file://" + videoUrl.substring(8);
   
     new Promise((resolve, reject) => {
       window.resolveLocalFileSystemURL(
         videoUrl,
         function (entry) {
           entry.file(
             function (file) {
               setTimeout(() => {
                 const reader = new FileReader();
                 reader.onloadend = function () {
                   resolve([this.result, file, entry]);
                 };
                 reader.onerror = function (ev) {
                   reject(ev);
                 };
                 reader.readAsArrayBuffer(file);
               }, 1000);
             },
             function (err) {
               reject(err);
             }
           );
         },
         function (err) {
           reject(err);
         }
       );
     });
   }
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org