Author: ygrego Date: 2015-03-02 10:08:34 +0000 (Mon, 02 Mar 2015) New Revision: 902 Url: http://forge.nuiton.org/projects/sandbox/repository/revisions/902 Log: Addition of method "channelSwitch". In fact, the code present initially in "prevChannel" has been moved to "channelSwitch" in order to also be used in "nextChannel". "prevChannel" and "nextChannel" are very similar. Modified: oipf/js/impl/VideoBroadcastObject.js Modified: oipf/js/impl/VideoBroadcastObject.js =================================================================== --- oipf/js/impl/VideoBroadcastObject.js 2015-03-02 09:29:09 UTC (rev 901) +++ oipf/js/impl/VideoBroadcastObject.js 2015-03-02 10:08:34 UTC (rev 902) @@ -373,63 +373,7 @@ * */ prevChannel: function() { - //claimed scarce resources - //Call method to claim scarce resources - - var channelConfig = this.getChannelConfig(); - var favouriteLists = channelConfig.favouriteLists; - //Verify that OITF maintain channel list or favourite list by itself - if (channelConfig && favouriteLists && (this.playstate > 0) && (this.playstate < 4)) { - - //Verify that the currentChannel exists in the channel list of channel configuration - if (!channelConfig.channelList.getChannel(this.currentChannel.channelId)) { - var self = this; - setTimeout(function () { - self.onChannelChangeError && self.onChannelChangeError(null, 100); - }, 0); - - if (this.playstate == 1) { - self = this; - setTimeout(function () { - self.onPlayStateChange && self.onPlayStateChange(0, 100); - }, 0); - } - } else { - - /* - * The norm affirm that the value "undefined" for the property "currentFavouriteList" - * means no current favourite list is activating. - * But test on this value for "currentFavouriteList" can cause confusion - * and when her value equals null, we have not the wanted behaviours. - */ - if (channelConfig.currentFavouriteList.length == 0) { - //Find the previous channel into channel list - var channelCollection = channelConfig.channelList; - } else { - //Find the previous channel into the current favourite list - channelCollection = channelConfig.currentFavouriteLists; - } - var _channelTools = new ChannelTools(); - var previousChannel = _channelTools.findChannel(channelCollection, this.currentChannel, - 1); - var tunerFound = _channelTools.verifyASuitableTunerAvailable(previousChannel.idType, this); - if (tunerFound) { - //ToDO: Error handling, if the switch fail, this instruction correspond to channel switch. - this.currentChannel = previousChannel; - self = this; - setTimeout(function () { - self.onPlayStateChange && self.onPlayStateChange(1); - self.onChannelChangeSucceeded && self.onChannelChangeSucceeded(previousChannel); - }, 0); - } - } - - } else { - //When the OITF does not maintain channel list or favourite list by itself - self = this; - setTimeout(function () { - self.onChannelChangeError && self.onChannelChangeError(null, 10); - }, 0); - } + this._channelSwitch(this, -1); }, /* * Description: @@ -464,8 +408,7 @@ * */ nextChannel: function() { - - + this._channelSwitch(this, 1); }, /* * Description: @@ -477,7 +420,6 @@ * • Channel channel – the channel to which the tuner switched. This object SHALL have the same properties with the same values as the currentChannel object (see * section 7.13.7). */ setFullScreen: function(fullscreen) { - }, /* * Description: @@ -489,7 +431,6 @@ * • Channel channel – the channel to which the tuner switched. This object SHALL have the same properties with the same values as the currentChannel object (see * section 7.13.7). */ setVolume: function(volume) { - }, /* * Description: @@ -501,8 +442,6 @@ * • Channel channel – the channel to which the tuner switched. This object SHALL have the same properties with the same values as the currentChannel object (see * section 7.13.7). */ getVolume: function() { - - }, /* * Description: @@ -514,8 +453,6 @@ * • Channel channel – the channel to which the tuner switched. This object SHALL have the same properties with the same values as the currentChannel object (see * section 7.13.7). */ release: function() { - - }, /* * Description: @@ -529,7 +466,65 @@ * • Channel channel – the channel to which the tuner switched. This object SHALL have the same properties with the same values as the currentChannel object (see * section 7.13.7). */ stop: function() { + }, + + _channelSwitch: function(object, step) { + //claimed scarce resources + //Call method to claim scarce resources + var channelConfig = object.getChannelConfig(); + var favouriteLists = channelConfig.favouriteLists; + //Verify that OITF maintain channel list or favourite list by itself + if (channelConfig && favouriteLists && (object.playstate > 0) && (object.playstate < 4)) { + //Verify that the currentChannel exists in the channel list of channel configuration + if (!channelConfig.channelList.getChannel(object.currentChannel.channelId)) { + var self = object; + setTimeout(function () { + self.onChannelChangeError && self.onChannelChangeError(null, 100); + }, 0); + + if (object.playstate == 1) { + self = object; + setTimeout(function () { + self.onPlayStateChange && self.onPlayStateChange(0, 100); + }, 0); + } + } else { + + /* + * The norm affirm that the value "undefined" for the property "currentFavouriteList" + * means no current favourite list is activating. + * But test on this value for "currentFavouriteList" can cause confusion + * and when her value equals null, we have not the wanted behaviours. + */ + if (channelConfig.currentFavouriteList.length == 0) { + //Find the previous channel into channel list + var channelCollection = channelConfig.channelList; + } else { + //Find the previous channel into the current favourite list + channelCollection = channelConfig.currentFavouriteLists; + } + var _channelTools = new ChannelTools(); + var previousChannel = _channelTools.findChannel(channelCollection, object.currentChannel, step); + var tunerFound = _channelTools.verifyASuitableTunerAvailable(previousChannel.idType, object); + if (tunerFound) { + //ToDO: Error handling, if the switch fail, this instruction correspond to channel switch. + object.currentChannel = previousChannel; + self = object; + setTimeout(function () { + self.onPlayStateChange && self.onPlayStateChange(1); + self.onChannelChangeSucceeded && self.onChannelChangeSucceeded(previousChannel); + }, 0); + } + } + + } else { + //When the OITF does not maintain channel list or favourite list by itself + self = object; + setTimeout(function () { + self.onChannelChangeError && self.onChannelChangeError(null, 10); + }, 0); + } } }); \ No newline at end of file
participants (1)
-
ygrego@users.nuiton.org