I have a service called 'player' and I need to update the service when a flash object is finished loading.
mySongPlayer.factory('player', function() {
var isPlayerLoaded = false;
var playerHolder = '';
window.playerReady = function(thePlayer) {
playerHolder = window.document[thePlayer.id];
addListeners();
isPlayerLoaded = true;
}
var flashvars = {
file:"",
autostart:"true",
skin: "/skins/glow/glow.zip",
}
var params = {
allowfullscreen:"false",
allowscriptaccess:"always"
}
var attributes = {
id:"player1",
name:"player1"
}
swfobject.embedSWF("/player.swf", "player_placeholder", "100%", "40", "9.0.115", false, flashvars, params, attributes);
var playObj;
return playObj || (playObj = {
currentId: 'test', currentUrl: 'url', playerHolder: ''
});
});
I know how to access the service using
angular.element(DOMElement).injector().get('player')
but it returns a new instance of 'player' while I need to update the instance already created in the module. Is there a way to do this? I only want one instance of the player, but I need to initialize it from outside javascript.