在WhatsApp中收听其他音频时,如何减少离子应用程序中的音频流音量

时间:2020-10-31 18:38:49

标签: angular ionic4

我正在开发一个离子应用程序,以实时传输音频。我正在使用HTMLAudioElement中的Audio()来执行此操作,而ionic应用程序可以在后台运行。

我想知道当应用程序用户收听设备中的另一种音频(例如WhatsApp Audio,Youtube Video,Facebook视频等)时如何减少音频流,以及当应用程序用户停止另一种音频/视频

按照我的实现下面的步骤播放和停止音频流:

export class Component implements OnInit {

     public myAudio = new Audio(this.STREAM_URL);

   .....
}

要播放音频,我称为此方法

/**
* This method is responsible to play the audio stream
*
* @memberof HomePage
*/
public play() {
  this.showPlayBtn = !this.showPlayBtn;
  this.myAudio.play();
}

要停止音频,我调用此方法

 /**
  * This method is responsible to play the audio stream
  *
  * @memberof HomePage
*/
 public play() {
   this.showPlayBtn = !this.showPlayBtn;
   this.myAudio.play();
 }

0 个答案:

没有答案
相关问题