Author: ygrego Date: 2015-03-30 13:47:10 +0000 (Mon, 30 Mar 2015) New Revision: 981 Url: http://forge.nuiton.org/projects/sandbox/repository/revisions/981 Log: Addition of property "_eventManager" and methods "addEventListener", "_fireEvent", "removeEventListener". Modified: oipf/js/impl/VideoBroadcastObject.js Modified: oipf/js/impl/VideoBroadcastObject.js =================================================================== --- oipf/js/impl/VideoBroadcastObject.js 2015-03-30 12:44:49 UTC (rev 980) +++ oipf/js/impl/VideoBroadcastObject.js 2015-03-30 13:47:10 UTC (rev 981) @@ -148,6 +148,7 @@ this._listeners = {}; this._callbacks = {}; this._channelService = channelService; + this._eventManager = new EventManager; }, /*! @@ -371,9 +372,21 @@ return this.currentChannel; }, + addEventListener: function(type, listener) { + this._eventManager.addEventListener(type, listener, this); + }, + + _fireEvent: function(event) { + this._eventManager.fireEvent(event, this); + }, + + removeEventListener: function(type, listener) { + this._eventManager.removeEventListener(type, listener, this); + }, + changePlayState: function(state, error) { this.playState = state; - this.fireEvent(createCustomEvent("PlayStateChange", [this.playState, error])); + this._fireEvent(createCustomEvent("PlayStateChange", [this.playState, error])); }, noTransientError: function(channel){ @@ -394,7 +407,7 @@ if (this.noTransientError(this._CONNECTING) && this.noPermanentError(this._CONNECTING, channel)) { this.playState = this._CONNECTING; - this.fireEvent(createCustomEvent("PlayStateChange", [this.playState])); + this._fireEvent(createCustomEvent("PlayStateChange", [this.playState])); timeout(0) .then(this.changeStateToPresentingWhenSwitching.bind(this, channel)); } @@ -405,9 +418,9 @@ if (this.noTransientError(this._PRESENTING)) { this.setCurrentChannel(channel); this.playState = this._PRESENTING; - this.fireEvent(createCustomEvent("PlayStateChange", [this.playState])); + this._fireEvent(createCustomEvent("PlayStateChange", [this.playState])); timeout(0) - .then(this.fireEvent.bind(this, createCustomEvent("ChannelChangeSucceeded", [channel]))); + .then(this._fireEvent.bind(this, createCustomEvent("ChannelChangeSucceeded", [channel]))); } }, @@ -636,7 +649,7 @@ } else { timeout(0) - .then(this.fireEvent.bind(this, createCustomEvent("ChannelChangeError", [null, 100]))); + .then(this._fireEvent.bind(this, createCustomEvent("ChannelChangeError", [null, 100]))); } } else { @@ -831,7 +844,7 @@ //Verify that the currentChannel exists in the channel list of channel configuration if (!channelConfig.channelList.getChannel(this.currentChannel.channelId)) { timeout(0) - .then(this.fireEvent.bind(this, createCustomEvent("ChannelChangeError", [null, 100]))); + .then(this._fireEvent.bind(this, createCustomEvent("ChannelChangeError", [null, 100]))); /*setTimeout(function () { self.onChannelChangeError && self.onChannelChangeError(null, 100); }, 0);*/ @@ -870,13 +883,13 @@ } else { //When the OITF does not maintain channel list or favourite list by itself timeout(0) - .then(this.fireEvent.bind(this, createCustomEvent("ChannelChangeError", [null, 10]))); + .then(this._fireEvent.bind(this, createCustomEvent("ChannelChangeError", [null, 10]))); } } else { //When this method is called in play state UNREALIZED timeout(0) - .then(this.fireEvent.bind(this, createCustomEvent("ChannelChangeError", [null, 100]))); + .then(this._fireEvent.bind(this, createCustomEvent("ChannelChangeError", [null, 100]))); } } }); \ No newline at end of file
participants (1)
-
ygregoï¼ users.nuiton.org