Tuesday, March 28, 2023
HomeiOS Developmentangular - convert from video uri to blob will not be engaged...

angular – convert from video uri to blob will not be engaged on iOS utilizing ionic framework


I’m utilizing the next code to transform the video file to blob for iOS.


    Takevideo()
      {
          const choices: CameraOptions = {
            sourceType: this.digicam.PictureSourceType.PHOTOLIBRARY, 
            destinationType: this.digicam.DestinationType.DATA_URL,
            mediaType: this.digicam.MediaType.VIDEO      
          }
            this.digicam.getPicture(choices).then(async (videoUrl) => {
              debugger;
              this.selectvideopath=null;
              var filename = videoUrl.substr(videoUrl.lastIndexOf("https://stackoverflow.com/") + 1);
              var dirpath = videoUrl.substr(0, videoUrl.lastIndexOf("https://stackoverflow.com/") + 1);
    
              dirpath = dirpath.contains("file://") ? dirpath : "file://" + dirpath;
              attempt {
                var dirUrl = await this.file.resolveDirectoryUrl(dirpath);
                var retrievedFile = await this.file.getFile(dirUrl, filename, {});
                this.makeFileIntoBlob(retrievedFile.nativeURL);
              } catch(err) {
                return this.ionLoader.showAlert("One thing went mistaken.");
              }
             
             }, (err) => {
              // Deal with error
             });
      }
    
      makeFileIntoBlob(_imagePath) {
        return new Promise((resolve, reject) => {
          console.log("makefileintoblob", +_imagePath);
          let fileName = "";
          this.file
            .resolveLocalFilesystemUrl(_imagePath)
            .then(fileEntry => {
              let { title, nativeURL } = fileEntry;
    
              let path = nativeURL.substring(0, nativeURL.lastIndexOf("/"));
              console.log("path", path);
              console.log("fileName", title);
    
              fileName = title;
    
              var buffer=this.file.readAsArrayBuffer(path, title);
              console.log("makefileintoblob buffer: " +buffer);
              this.Videodatas.push({vdodata:buffer});
              return this.file.readAsArrayBuffer(path, title);
            })
            .then(buffer => {
              this.ionLoader.showAlert('2:'+buffer);
              console.log("makefileintoblob buffernew: " +buffer);
              let imgBlob = new Blob([buffer], {
                kind: "video/MOV"
              });
              console.log(imgBlob.kind, imgBlob.measurement);
              resolve({
                fileName,
                imgBlob
              });
            })
            .catch(e => reject(e));
        });
      }

  

However the next block will not be executed.


    .then(buffer => {
              this.ionLoader.showAlert('2:'+buffer);
              console.log("makefileintoblob buffernew: " +buffer);
              let imgBlob = new Blob([buffer], {
                kind: "video/MOV"
              });
              console.log(imgBlob.kind, imgBlob.measurement);
              resolve({
                fileName,
                imgBlob
              });

I’ve already put in the packages:
npm set up –save @ionic-native/file-transfer
npm set up cordova-plugin-file-transfer
npm set up cordova-plugin-file

Can anybody please assist me to resolve this difficulty.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments