как перейти на страницу, нажав кнопку назад на камере, открытой в ionic2 - PullRequest
0 голосов
/ 07 сентября 2018

У меня есть HomePage и в ionViewWillEnter () я добавил код камеры. Так что, когда HomePage получает триггер, он сначала открывает камеру

Я хочу настроить поведение кнопки «Назад», чтобы при нажатии кнопки «Назад» после открытия камеры она переходила на SecondPage, по умолчанию - на HomePage.

ionViewWillEnter() {
   this.captureVideo();
 }


 captureVideo() {
    platform.registerBackButtonAction(() => {
      this.navCtrl.push(SecondPage)
       });
    let options: CaptureVideoOptions = { limit: 1 };
    this.mediaCapture.captureVideo(options)
     .then((videodata: MediaFile[]) => {
      var i, path, len;
     for (i = 0, len = videodata.length; i < len; i += 1) {
      path = videodata[i].fullPath;

      }

      this.flag_play = false;
      this.flag_upload = false;


     this.file.resolveLocalFilesystemUrl(path).then((newUrl) => {
     alert(JSON.stringify(newUrl))
     let dirPath = newUrl.nativeURL;
     let dirPathSegments = dirPath.split('/')
     dirPathSegments.pop()
     dirPath = dirPathSegments.join('/')
     this.file.readAsArrayBuffer(dirPath, newUrl.name).then(async (buffer) 
        => {
        await this.upload(buffer, newUrl.name);

          })

        })
        })
     .then(() => {


       var videoFileName = 'video-name-here'; 

       this.videoEditor.createThumbnail(

        {
         fileUri:'abc',// this.videoId,
         outputFileName: videoFileName,
         atTime: 2,
         width: 320,
         height: 480,
         quality: 100
        }
       ).then(result => {



     this.result = result;
     this.base64.encodeFile(result).then((base64File) => {
      this.base64Thumbnail = base64File.replace("*;charset=utf-8", "jpg")

       }, err => {

       alert("Unable to create thumbnail")
      })

       })
       })

       }

1 Ответ

0 голосов
/ 08 сентября 2018

Аппаратная кнопка «Назад» работает как режим отмены ... по умолчанию, поэтому для ее настройки необходимо указать код ошибки ...

  takePicture(){
    this.camera.getPicture({
       destinationType: this.camera.DestinationType.DATA_URL,
      targetWidth: 1000,
      targetHeight: 1000
     }).then((imageData) => {
  // imageData is a base64 encoded string
       this.base64Image = "data:image/jpeg;base64," + imageData;
    }, (err) => {
   this.navCtrl.pop();

   });
  }
  }
...