How to play only one audio at a time

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.

just managed to achieve what i want.
Hopefully i m doing it in the right way.

var sound_on = false;
var media = new Media( ‘/android_asset/www/files/test.mp3’);
$scope.playAudio = function(filename, duration) {

if (sound_on == true) {
  media.stop();
  media.release();
}
sound_on = true;
media = $cordovaMedia.newMedia('/android_asset/www/files/' + filename + '.mp3');
media.play();
$timeout(function(){
     sound_on = false;
     }, duration);

}