I don't quite follow how to inject external constructors, I have this constructor:
function myAudio(url){
var song = new Audio();
song.crossOrigin = "anonymous";
song.src = url;
var source = context.createMediaElementSource(song);
source.connect(context.destination);
this.play = function(){
source.mediaElement.play();
}
}
outside, just with Javascript it works ok. I can create objects using var myVar = new myAudio("some_url")
I want to use that constructor inside an AngularJS controller but I just can't figure out how to do it.
I tried declaring it in the controller without success
app.controller("myAppCtrl", myMainFunction);
myMainFunction.$inject = ["$interval", "myAudio"];
function myMainFunction($interval, myAudio) {
scope = this;
//my controller stuff
}
Tried to make it return an object but I didn't find the correct way to do it.
I don't know what I am missing...