Author: ygrego Date: 2015-03-13 16:42:16 +0000 (Fri, 13 Mar 2015) New Revision: 950 Url: http://forge.nuiton.org/projects/sandbox/repository/revisions/950 Log: Renaming of property "playstate" into "playState", use of variable "self" in all methods "setTimeout" use in this class, addition of method "setTimeout" in method "release" and "stop". Modified: oipf/js/impl/VideoBroadcastObject.js Modified: oipf/js/impl/VideoBroadcastObject.js =================================================================== --- oipf/js/impl/VideoBroadcastObject.js 2015-03-13 16:31:41 UTC (rev 949) +++ oipf/js/impl/VideoBroadcastObject.js 2015-03-13 16:42:16 UTC (rev 950) @@ -94,7 +94,7 @@ * call to bindToCurrentChannel() completes. Applications which do not need to call bindToCurrentChannel() should not do so. The current channel can * be obtained from the currentChannel property on the ApplicationPrivateData object which is the same as that on the video/broadcast object under most normal * conditions. */ - playstate: null, + playState: null, /* * Description: @@ -142,7 +142,7 @@ init: function (requiredCapabilities) { console.log("[INFO] constructor of VideoBroadcast class called."); - this.playstate = 0; + this.playState = 0; if (requiredCapabilities) { this.allocationMethod = STATIC_ALLOCATION_VIDEOBROADCAST; /* TODO: get scarce resources Scarce resources can be claimed by the video/broadcast or A/V Control object at instantiation time by specifying the @@ -296,7 +296,7 @@ var channelConfig = this.getChannelConfig(); var currentChan = channelConfig.currentChannel; var self = this; - switch (this.playstate) { + switch (this.playState) { case 0: //claimed scarce resources @@ -306,15 +306,15 @@ this.currentChannel = currentChan; setTimeout(function () { - this.playstate = 2; - self.onPlayStateChange && self.onPlayStateChange(this.playstate);//Parameter error here equals to 20 but not defined in the norm, means there is no error + self.playState = 2; + self.onPlayStateChange && self.onPlayStateChange(self.playState); }, 0); } else { setTimeout(function () { - this.playstate = 0; - self.onPlayStateChange && self.onPlayStateChange(this.playstate, 100); + self.playState = 0; + self.onPlayStateChange && self.onPlayStateChange(self.playState, 100); }, 0); } break; @@ -322,8 +322,8 @@ case 3: setTimeout(function () { //Make enable video and audio presentation - this.playstate = 1; - self.onPlayStateChange && self.onPlayStateChange(this.playstate); + self.playState = 1; + self.onPlayStateChange && self.onPlayStateChange(self.playState); }, 0); break; @@ -525,15 +525,38 @@ }, /* - * Description: - * The function that is called when a request to switch a tuner to another channel has successfully completed. - * This function may be called either in response to a channel change initiated by the application, or a channel - * change initiated by the OITF (see section 7.13.1.1). The specified function is called with argument channel, - * which is defined as follows: - * - * • 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). + * Description: (Validation on Transport Stream won't be done here because this criteria not relevant) + * Requests the OITF to switch a (logical or physical) tuner to the channel specified by + * channel and render the received broadcast content in the area of the browser allocated for + * the video/broadcast object. + * + * If the channel specifies an idType attribute value which is not supported by the OITF or a + * combination of properties that does not identify a valid channel, the request to switch + * channel SHALL fail and the OITF SHALL trigger the function specified by the + * onChannelChangeError property, specifying the value 0 (“Channel not supported by + * tuner”) for the errorState , and dispatch the corresponding DOM event (see below). + * + * */ setChannel: function(channel, trickplay, contentAccessDescriptorURL) { + + if ((this.playState >= 1) && (this.playState <= 3) && (!channel)) { + var tuner = verifyASuitableTunerAvailable(this, channel.idType); + + if (tuner) { + + } + + } else { + var self = this; + + setTimeout(function () { + self.playState = 0; + self.release(); + self.onPlayStateChange && self.onPlayStateChange(self.playState); + }, 0); + + } }, /* @@ -683,16 +706,23 @@ * the releasing of resources shall change this to DYNAMIC_ALLOCATION . */ release: function() { - if ((this.playstate >= 1) && (this.playstate <= 3)) { + if ((this.playState >= 1) && (this.playState <= 3)) { /* Call method to : * - release tuner used by this video/broadcast object. * - stop visualization of the video. * - and scarce ressources loaded previously. */ - this.playstate = 0; - this.currentChannel = null; - this.allocationMethod = (this.allocationMethod == STATIC_ALLOCATION_VIDEOBROADCAST) ? DYNAMIC_ALLOCATION_VIDEOBROADCAST : this.allocationMethod; - this.onPlayStateChange && this.onPlayStateChange(0); + var self = this; + console.log("Hey Hey"); + setTimeout(function () { + self.playState = 0; + self.currentChannel = null; + self.allocationMethod = (self.allocationMethod == STATIC_ALLOCATION_VIDEOBROADCAST) ? DYNAMIC_ALLOCATION_VIDEOBROADCAST : self.allocationMethod; + self.onPlayStateChange && self.onPlayStateChange(self.playState); + }, 0); + + this.playState = 0; + } }, @@ -707,14 +737,18 @@ * */ stop: function() { - if ((this.playstate >= 1) && (this.playstate <= 2)) { + if ((this.playState >= 1) && (this.playState <= 2)) { /* Call method to : * - stop the presentation of the video and audio. * - and scarce ressources loaded previously. */ - this.playstate = 3; this.release(); - this.onPlayStateChange && this.onPlayStateChange(3); + var self = this; + console.log("Hey"); + setTimeout(function () { + self.playState = 3; + self.onPlayStateChange && self.onPlayStateChange(self.playState); + }, 0); } }, @@ -724,8 +758,9 @@ 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)) { + 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)) { @@ -734,11 +769,11 @@ self.onChannelChangeError && self.onChannelChangeError(null, 100); }, 0); - if (object.playstate == 1) { + if (object.playState == 1) { self = object; setTimeout(function () { - this.playstate = 0; - self.onPlayStateChange && self.onPlayStateChange(this.playstate, 100); + self.playState = 0; + self.onPlayStateChange && self.onPlayStateChange(self.playState, 100); }, 0); } } else { @@ -765,8 +800,8 @@ object.currentChannel = previousChannel; self = object; setTimeout(function () { - this.playstate = 1; - self.onPlayStateChange && self.onPlayStateChange(this.playstate); + self.playState = 1; + self.onPlayStateChange && self.onPlayStateChange(self.playState); self.onChannelChangeSucceeded && self.onChannelChangeSucceeded(previousChannel); }, 0); }
participants (1)
-
ygrego@users.nuiton.org