Author: ygrego Date: 2015-04-01 12:28:25 +0000 (Wed, 01 Apr 2015) New Revision: 1015 Url: http://forge.nuiton.org/projects/sandbox/repository/revisions/1015 Log: Timer invocation will perform by new object "_timerManager", a copy of his method "createTimer" is saved in "_timeout", all those modifications have been done in mehtod "init". Now each timer invocation is performed by call of method "_timeout", it the main modification of this commit. Modified: oipf/js/impl/VideoBroadcastObject.js Modified: oipf/js/impl/VideoBroadcastObject.js =================================================================== --- oipf/js/impl/VideoBroadcastObject.js 2015-04-01 12:12:09 UTC (rev 1014) +++ oipf/js/impl/VideoBroadcastObject.js 2015-04-01 12:28:25 UTC (rev 1015) @@ -148,7 +148,11 @@ this._listeners = {}; this._callbacks = {}; this._channelService = channelService; - this._eventManager = new EventManager; + this._eventManager = new EventManager(); + this._timerManager = new TimerManager(); + + this._timeout = this._timerManager.createTimer.bind(this._timerManager, 0); + this._timeoutLong = this._timerManager.createTimer.bind(this._timerManager, 100); }, /*! @@ -315,8 +319,6 @@ bindToCurrentChannel: function() { var channelConfig = this._channelService; var currentChannel = channelConfig.currentChannel; - - this._timer && this._timer.cancel(); switch (this.playState) { @@ -324,31 +326,32 @@ //claimed scarce resources //Call method to claim scarces resources if (currentChannel) { - this._timer = oipf.utils.timeout(0) + this._timeout() .then(this.changePlayState.bind(this, this._CONNECTING)) .then(this.setCurrentChannel.bind(this, currentChannel)) + .then(this._timeout) .then(this.changePlayState.bind(this, this._PRESENTING)); } else { - this._timer = oipf.utils.timeout(0) + this._timeout() .then(this.changePlayState.bind(this, this._UNREALIZED, 100)); } break; case this._CONNECTING: - /*if (!verifyASuitableTunerAvailable(currentChannel.idType)) { - this.timer = oipf.utils.timeout(0) - .then(this.changePlayState.bind(this, this._CONNECTING)); + if (!channelUtils.verifyASuitableTunerAvailable(currentChannel.idType)) { + this._timeout() + .then(this.changePlayState.bind(this, this._CONNECTING)); } else { - this.timer = oipf.utils.timeout(0) - .then(this.setCurrentChannel.bind(this, currentChannel)) - .then(this.changePlayState.bind(this, this._PRESENTING)); - }*/ + this._timeout() + .then(this.setCurrentChannel.bind(this, currentChannel)) + .then(this.changePlayState.bind(this, this._PRESENTING)); + } //Method documentation indicate it don't have effects in this state. break; case this._PRESENTING: /*if (!verifyASuitableTunerAvailable(currentChannel.idType)) { - this.timer = oipf.utils.timeout(0) + this.timer = oipf.utils.this._timeout() .then(this.changePlayState.bind(this, this._PRESENTING)); }*/ //Method documentation indicate it don't have effects in this state. @@ -357,18 +360,17 @@ case this._STOPPED: //FIX-ME :Make enable video and audio presentation if (!channelUtils.verifyASuitableTunerAvailable(currentChannel.idType, this)) { - this._timer = oipf.utils.timeout(0) - .then(this.changePlayState.bind(this, this._STOPPED, 0)); + this._timeout() + .then(this.changePlayState.bind(this, this._STOPPED, 0)); } else { - this._timer = oipf.utils.timeout(0) - .then(this.changePlayState.bind(this, this._CONNECTING)) - .then(this.setCurrentChannel.bind(this, currentChannel)) - .then(this.changePlayState.bind(this, this._PRESENTING)); + this._timeout() + .then(this.changePlayState.bind(this, this._CONNECTING)) + .then(this.setCurrentChannel.bind(this, currentChannel)) + .then(this._timeout) + .then(this.changePlayState.bind(this, this._PRESENTING)); } break; - } - return this.currentChannel; }, @@ -385,6 +387,7 @@ }, changePlayState: function(state, error) { + console.log("changeState", state); this.playState = state; this._fireEvent(createCustomEvent("PlayStateChange", [this.playState, error])); }, @@ -408,7 +411,7 @@ if (this.noTransientError(this._CONNECTING) && this.noPermanentError(this._CONNECTING, channel)) { this.playState = this._CONNECTING; this._fireEvent(createCustomEvent("PlayStateChange", [this.playState])); - timeout(0) + this._timeout() .then(this.changeStateToPresentingWhenSwitching.bind(this, channel)); } }, @@ -419,7 +422,7 @@ this.setCurrentChannel(channel); this.playState = this._PRESENTING; this._fireEvent(createCustomEvent("PlayStateChange", [this.playState])); - timeout(0) + this._timeout() .then(this._fireEvent.bind(this, createCustomEvent("ChannelChangeSucceeded", [channel]))); } }, @@ -644,18 +647,17 @@ if (this.playState >= this._CONNECTING && this.playState <= this._STOPPED && channel) { if (channelUtils.verifyASuitableTunerAvailable(channel.idType, this) && channel.idType != 41) { - timeout(0) + this._timeout() .then(this.changeStateToConnectingWhenSwitching.bind(this, channel)); } else { - timeout(0) + this._timeout() .then(this._fireEvent.bind(this, createCustomEvent("ChannelChangeError", [null, 100]))); } } else { - timeout(0) - //.then(this.release.bind(this)) + this._timeout() .then(this.changePlayState.bind(this, this._UNREALIZED)); } }, @@ -803,9 +805,9 @@ * - stop visualization of the video. * - and scarce ressources loaded previously. */ - this._timer && this._timer.cancel(); - this._timer = oipf.utils.timeout(0) + + this._timeout() .then(this.changePlayState.bind(this, this._UNREALIZED)); } }, @@ -826,9 +828,9 @@ * - stop the presentation of the video and audio. * - and scarce ressources loaded previously. */ - this._timer && this._timer.cancel(); - this._timer = oipf.utils.timeout(0) + + this._timeout() .then(this.changePlayState.bind(this, this._STOPPED)); } }, @@ -846,14 +848,14 @@ //Verify that the currentChannel exists in the channel list of channel configuration if (!channelConfig.channelList.getChannel(this.currentChannel.channelId)) { - timeout(0) + this._timeout() .then(this._fireEvent.bind(this, createCustomEvent("ChannelChangeError", [null, 100]))); /*setTimeout(function () { self.onChannelChangeError && self.onChannelChangeError(null, 100); }, 0);*/ if (this.playState == 1) { - timeout(0) + this._timeout() .then(this.changePlayState.bind(this, this._UNREALIZED, 100)); /*setTimeout(function () { self.playState = 0; @@ -878,14 +880,14 @@ var channelToChange = channelUtils.findChannel(channelCollection, this.currentChannel, step); if (channelUtils.verifyASuitableTunerAvailable(channelToChange.idType, this)) { - timeout(0) + this._timeout() .then(this.changeStateToConnectingWhenSwitching.bind(this, channelToChange)); } else if (channelToChange.idType == 40 || channelToChange.idType == 41) { - timeout(0) + this._timeout() .then(object._fireEvent.bind(object, createCustomEvent("ChannelChangeError", [null, 8]))); } else { - timeout(0) + this._timeout() .then(object._fireEvent.bind(object, createCustomEvent("ChannelChangeError", [null, 0]))); } @@ -893,13 +895,13 @@ } else { //When the OITF does not maintain channel list or favourite list by itself - timeout(0) + this._timeout() .then(this._fireEvent.bind(this, createCustomEvent("ChannelChangeError", [null, 10]))); } } else { //When this method is called in play state UNREALIZED - timeout(0) + this._timeout() .then(this._fireEvent.bind(this, createCustomEvent("ChannelChangeError", [null, 100]))); } }
participants (1)
-
ygregoï¼ users.nuiton.org