Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AngularJS error while using ngAudio

I am trying to play audio using AngualarJs

My HTML CODE:

<!doctype HTML>
<html>
<head>
</head>
<body ng-app="test" ng-controller="audioTest">
    <button ng-click="playSound()"></button>
    <script src="javascripts/angular.min.js"></script>
    <script        src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js">   </script>
     <script src="javascripts/angular.audio.js"></script>
    <script src="app.js"></script>

</body>
</html>

My app.js Code:

var app  = angular.module("test",['ngAudio']);

var audio = app.controller("audioTest",function($scope,ngAudio){
$scope.playSound = function(){
    $scope.audio = ngAudio.load("abc.wav");
   $scope.audio.play();
}
});

While i load page i got error in console which lead me to Error Details

like image 880
vishal patel Avatar asked Oct 31 '22 05:10

vishal patel


1 Answers

The error you're reporting is due to an error resolving angular.audio.js script that can't be found by the name javascripts/angular.audio.js

I made a working fiddle: http://jsfiddle.net/en8x1nny/

This fiddle imports the script that the original demo from ngAudio is using.

The full path for that script is: http://danielstern.github.io/ngAudio/angular.audio.js.

You can download it and add it to your javascripts directory. Be sure not to use it by the URL mentioned above because github is not a CDN intended to serve scripts.

If you previously installed ngAudio by bower, the script should be in:

your_project_path/bower_components/angular-audio/app/angular.audio.js
like image 186
Cyberdelphos Avatar answered Nov 02 '22 23:11

Cyberdelphos