Advertisement
Guest User

Untitled

a guest
Dec 11th, 2019
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. playAudio() {
  2. this.filePath = this.file.externalDataDirectory.replace(/file:\/\//g, '') + '_temp_audio.mp3';
  3.  
  4. this.audioMedia = this.media.create(this.filePath);
  5. this.audioMedia.play();
  6. this.audioMedia.onStatusUpdate.subscribe((status) => {
  7. if(status == 1) { this.isPlaying = true; }
  8. if(status == 4) { this.stopAudio(); }
  9. this.cd.detectChanges();
  10. });
  11.  
  12. this.isPlaying = true;
  13. }
  14.  
  15. stopAudio() {
  16. this.audioMedia.stop();
  17. this.isPlaying = false;
  18. }
  19.  
  20. startRecord() {
  21. this.filePath = this.file.externalDataDirectory.replace(/file:\/\//g, '') + '_temp_audio.mp3';
  22.  
  23. //if(this.siteService.isPlaying) { this.dropPlay = true; this.siteService.emitPlayer(); }
  24.  
  25. this.audioMedia = this.media.create(this.filePath);
  26. this.audioMedia.startRecord();
  27. this.recording = true;
  28. this.timerStart();
  29. }
  30.  
  31. stopRecord() {
  32. this.audioMedia.stopRecord();
  33. this.audioMedia = this.media.create(this.filePath);
  34.  
  35. this.counting = false; this.recording = false; this.hasFile = true;
  36.  
  37. if(!this.siteService.isPlaying && this.dropPlay) { this.siteService.emitPlayer(); }
  38. this.dropPlay = true;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement