So when the user clicks a button an audio file plays from an array of audio files(around 2 sec clip), which works fine. However, if the user repeatedly clicks the button, the audio files start to play over each other. Ideally, I would like to stop/pause the previous audio file and then play the new audio file. This is what I've tried to avail:
$scope.sounder=function(){ $scope.rs=$scope.diff[$scope.workout_index].audiorep; $scope.ms=$scope.diff[$scope.workout_index].audiomove; //var movesound = new Audio ($scope.ms); //ar repsound = new Audio ($scope.rs); var movesound = new Media($rootScope.getMediaURL($scope.ms)); var repsound = new Media($rootScope.getMediaURL($scope.rs)); if($scope.muter==0){ movesound.pause();//DOES NOT WORK movesound.stop();//STOPS ALL AUDIO FROM PLAYING, SO NOTHING PLAYS $timeout(function() { movesound.play(); }, 1000); $timeout(function() { repsound.play(); }, 3000); } if($scope.muter==1){ console.log("Rachel has been muted"); return; } }