Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 70612

How to play only one audio at a time

$
0
0

@nayha wrote:

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.

Posts: 2

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 70612

Trending Articles



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