Quantcast
Channel: Ionic Forum - Latest posts
Viewing all articles
Browse latest Browse all 228595

How to play only one audio at a time

$
0
0

I am using cordova media plugin

in my Controller:

  $scope.playAudio = function(src) {
    src = '/android_asset/www/files/' + src;
    var media = $cordovaMedia.newMedia(src);
    media.play();
  }

Template HTML:

<img src="img/speaker.png" ng-click="playAudio('test.mp3')" />

The audio file is only 10 seconds long.
When I click the speaker icon, the audio plays fine.
When i click again before the audio finished, another instance starts playing without stopping the previous one.
I'd like know how to stop the current playing instance first.
Thanks.


Viewing all articles
Browse latest Browse all 228595

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>