The sound bug with cordova media plugin and ionic2


#1

hi, i try to play a sound in my ionic2 app and media plugin but the sound starts and bugs and stops my application ! I have android version 4.2.1

If i play the sound when i click on a button it works. But when the event come from a GUI refesh event it bugs :frowning:

In fact, i the sound is repeated indefinitly !

 getLabelGameResult() {
switch (this.gameResult) {
  case PLAYER1_WIN :
    this.platform.ready().then(() => {
      if (this.platform.is('android'))new MediaPlugin(this.getMediaURL('sound/win.wav')).play();
    });
    return 'Player 1 win';
  case PLAYER2_WIN :
    this.platform.ready().then(() => {
      if (this.platform.is('android'))new MediaPlugin(this.getMediaURL('sound/loose.wav')).play();
    });
    return 'Player 2 win';
  case PLAYER_DRAW :
    return 'Draw';
}
return 'Play the game';

}

  <ion-item>
    <h1>{{ this.getLabelGameResult() }}</h1>
  </ion-item>