[MOBILE] angular.audio.js:295 Uncaught (in promise) DOMException: play() can only be initiated by a user gesture.
Opened this issue · 2 comments
Deleted user commented
The intended behaviour works fine on desktop, but not on mobile. Here is a sample of the code:
Working Button:
<button type="button" ng-click="sound.paused ? sound.play($scope.data[index].mp3) : pauseAudio()"><i class="fa" ng-class="sound.paused ? 'fa-play' : 'fa-pause'"></i></button>
Not Working Button:
<button type="button" ng-click="sound.paused ? playAudio(index) : pauseAudio()"><i class="fa" ng-class="sound.paused ? 'fa-play' : 'fa-pause'"></i></button>
Pause Function:
$scope.pauseAudio = function() {
if ($scope.sound)
$scope.sound.stop();
};
Play Function:
$scope.playAudio = function(index) {
$scope.pauseAudio();
$timeout(function() {
if ($scope.data[index].mp3) {
ngAudio.unlock = true;
$scope.sound = ngAudio.load($scope.data[index].mp3);
$scope.sound.volume = 0.75;
$scope.sound.play();
}
}, 100);
};
The issue is ngAudio.load in the playAudio function. It simply does not trigger on mobile. I require this function to trigger from other user interactions as well, but Chrome on Android/Safari seems to detect that they weren't gestured via a user input. My goal is to give the controller full control on mobile, without relying on playback functionality within the partial. Any advice?
Deleted user commented
Update: I was able to solve my issue by using the #140 pull.
danielstern commented
Merged