NickLusson commented on issue #169:
URL: 
https://github.com/apache/cordova-plugin-media-capture/issues/169#issuecomment-617215373


   ok, thank you.
   
   here is some code showing the issue, first the html showing 3 statements 
that I would like the user to record, and the capture audio button, and then 
the ts file:
   
   When you press the capture audio button it first asks for permission to use 
the microphone, then it opens the microphone in a full screen that covers the 
statements that I would like to be read, so the user can record but cannot see 
the statements they are supposed to read into the microphone.
   
   
   here is the html
   ```
   <ion-content>
     <ion-grid>
       <ion-row>
         <ion-col>
                <h1 class="ion-text-center">Record these statments</h1><br>
               <p class="ion-text-center">
                 Go somewhere quiet.. and record these statements with as much 
enthusiasim as you can!
               </p>
               1. I am worthy of success. I am worthy of peace.<br><br>
               2. I accept myself as I am. I love myself as I am. I release all 
limiting thoughts. I honor myself always.<br><br>
               3. I am fearless. I am Powerful.<br><br>
              
                       <div class="ion-text-center">
                         <ion-button color="danger" (click)="captureAudio()">
                           <ion-icon name="mic"></ion-icon>Capture 
Audio</ion-button>
                       </div>
                     
               <ion-list style="background-color:#f0f0f0">
                 <ion-radio-group value="1" required id="recordingradio">
                 <ion-item *ngFor="let file of mediaFiles" tappable 
(click)="play(file)" text-wrap>
                   My Recording
                   <ion-radio id="recording" name="recording" required 
value="1"></ion-radio><br><br><br>
                   <ion-button slot="end" color="success" href="/results" 
id="submit">
                     <ion-icon name="arrow-forward-circle" 
slot="start"></ion-icon>Continue</ion-button>
                 </ion-item>
                 </ion-radio-group>
               </ion-list>
         </ion-col>
       </ion-row>
     </ion-grid>
   </ion-content>
   ```
   
   Here is the .ts file
   ```
   import { Component, OnInit, ViewChild } from '@angular/core';
   import { NavController } from '@ionic/angular';
   import { MediaCapture, MediaFile, CaptureError, CaptureVideoOptions } from 
'@ionic-native/media-capture/ngx';
   import { Storage } from '@ionic/storage';
   import { Media, MediaObject } from '@ionic-native/media/ngx';
   import { File } from '@ionic-native/file/ngx';
   
   const MEDIA_FILES_KEY = 'mediaFiles';
   
   @Component({
     selector: 'app-confidence2',
     templateUrl: './confidence2.page.html',
     styleUrls: ['./confidence2.page.scss'],
   })
   export class Confidence2Page implements OnInit {
     mediaFiles = []
   
     constructor(public navCtrl: NavController, private mediaCapture: 
MediaCapture, private storage: Storage, private media: Media, private file: 
File) {}
   
     ionViewDidLoad() {
       this.storage.get(MEDIA_FILES_KEY).then(res => {
         this.mediaFiles = JSON.parse(res) || [];
       });
     }
   
     captureAudio(){
       this.mediaCapture.captureAudio().then(res => {
         this.storeMediaFiles(res);
       }, (err: CaptureError) => console.error(err));
     }
     
     play(myFile) {
       if (myFile.name.indexOf('wav.') > -1) {
         const audioFile: MediaObject = this.media.create(myFile.localURL);
         audioFile.play();
       } else {
         let path = this.file.dataDirectory + myFile.name;
         let url = path.replace(/file^\/\//, '');
         
       }
     }
   
     storeMediaFiles(files) {
       console.log('store: ', files);
       this.storage.get(MEDIA_FILES_KEY).then(res => {
         if (res) {
           let arr = JSON.parse(res);
           arr = arr.concat(files);
           this.storage.set(MEDIA_FILES_KEY, JSON.stringify(arr));
         } else {
           this.storage.set(MEDIA_FILES_KEY, JSON.stringify(files))
         }
         this.mediaFiles = this.mediaFiles.concat(files);
       })
     }
     ngOnInit() {
     }
   }
    ```


----------------------------------------------------------------
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:
us...@infra.apache.org



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

Reply via email to