How to select multiple image and video in ionic 3

Viewed 200

I'm developing a mobile application in Ionic Angular and I don't seem to be able to find a plugin that supports being able to select multiple pieces of media as well as both images and videos.

So far I've come across and tried two:

Ionic native camera

/**
   * Take picture from memory
   * @return {Void}
   */
  takePictureFromGallery() {
    let translation:string = this.translate.instant('album.showalert.temporary');
    this.camera.getPicture(this.galleryPickerOptions).then(
      (media: any) => {
        // Get temp album
        this.getTemporaryAlbumId().then(
          (tempAlbumId) => {

            // Create media object
            let mediaObj = {
              name: media.split('/').pop(),
              fullPath: media
            }
            // Add media into temp album
            this.albumProvider.addMedias(tempAlbumId, [mediaObj]).then(
              (result: any) => {
                this.showToastMessage(translation);
              },
              (error: any) => {
                this.handleAddMediaError(error);
                this.refresh();
              }
            );
          },
          (error: any) => {
            this.showToastMessage(error.message);
          }
        );
      },
      (error: any) => {
        // Show toast on error get media from gallery
        this.showToastMessage(error.message);
      }
    );
  }

https://ionicframework.com/docs/native/camera/

Ionic native image-picker

      /**
   * Take picture from memory
   * @return {Void}
   */ 
  selectAllPictures(): void {
    let options = {
      allow_video: true,
      maximumImagesCount: 300,
    }
    this.imagePicker.getPictures(options).then(
      (results) => {
        this.loading = this.loadingCtrl.create({
          spinner: "circles"
      });
        for (var i = 0; i < results.length; i++) {
          let mediaObj = {
            name : results[i].substring(results[i].lastIndexOf('/')+1),
            fullPath :  results[i]
          }
          this.albumProvider.addMedias(this.album.id, [mediaObj]).then(
            (result: any) => {
              this.loading.dismiss();
            },
            (error: any) => {
              this.handleAddMediaError(error);
            }
          );
        }
        this.refresh();
      }, (err) => { });
    } 

https://github.com/Telerik-Verified-Plugins/ImagePicker

My question is, does anyone know of an Ionic plugin that would allow me to open the gallery and allow the user to select multiple pieces of media - both images and video? The returned result would preferably be a file URI for each selected item but that is not a necessity.

Thanks

0 Answers
Related