Using an API to obtain the url of the sound to play in audio tag
View
<img src="../img/play.svg" alt="Play" ng-click="playSound('exampleWord')" width="48"/>
Controller:
$scope.playSound=function(input){
$scope.audio={};
soundFetch.getSound(input).success(function(data){
$scope.audio=data;
});
}
The soundFetch is the service to call the getSound function. The returning data is the url of the song.
How can I play the sound after clicking the img tag. Currently getting an error Error: [$interpolate:interr]
$scope.playAudio = function() {
var audio = new Audio('audio/song.mp3');
audio.play();
};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With