因此,當用戶單擊某個按鈕時,音頻文件將播放一系列音頻文件(大約2秒的剪輯),這很好。但是,如果用戶反覆點擊該按鈕,則音頻文件開始相互播放。理想情況下,我想停止/暫停先前的音頻文件,然後播放新的音頻文件。這是我一直試圖利用:如何暫停/停止播放音頻並替換爲新的音頻文件
$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;
}
}
你嘗試了movesound.destroy(); ? – MatMat
剛剛嘗試過,不允許任何文件播放。 – MehdiN