# HG changeset patch # User hamidouk # Date 1320683028 -3600 # Node ID 2e0205ee7ca99c32f8df8e18065a9529b0b9fd99 # Parent 4de73fd2c4f89806b5f35328d5c400ade3aba74e patch to respond to update the player widget when the user clicks directly on the html5/flash player window. diff -r 4de73fd2c4f8 -r 2e0205ee7ca9 src/js/widgets/playerWidget.js --- a/src/js/widgets/playerWidget.js Mon Nov 07 17:08:26 2011 +0100 +++ b/src/js/widgets/playerWidget.js Mon Nov 07 17:23:48 2011 +0100 @@ -71,6 +71,10 @@ } ); + // handle clicks by the user on the video. + this._Popcorn.listen("play", IriSP.wrap(this, this.playButtonUpdater)); + this._Popcorn.listen("pause", IriSP.wrap(this, this.playButtonUpdater)); + this._Popcorn.listen("timeupdate", IriSP.wrap(this, this.sliderUpdater)); this.selector.children("#amount").val(this.selector.children("#slider-range-min").slider("value")+" s"); this.selector.children(".Ldt-Control1 button:first").button({ @@ -110,20 +114,35 @@ }; -IriSP.PlayerWidget.prototype.playHandler = function() { +/* update the icon of the button - separate function from playHandler + because in some cases (for instance, when the user directly clicks on + the jwplayer window) we have to change the icon without playing/pausing +*/ +IriSP.PlayerWidget.prototype.playButtonUpdater = function() { var status = this._Popcorn.media.paused; if ( status == true ){ - this._Popcorn.play(); this.selector.find(".ui-icon-play").css( "background-position", "-16px -160px" ); this.selector.find("#ldt-CtrlPlay").attr("title", "Play"); } else { - this._Popcorn.pause(); this.selector.find(".ui-icon-play").css( "background-position","0px -160px" ); this.selector.find("#ldt-CtrlPlay").attr("title", "Pause"); } }; + +IriSP.PlayerWidget.prototype.playHandler = function() { + var status = this._Popcorn.media.paused; + + this.playButtonUpdater(); + + if ( status == true ){ + this._Popcorn.play(); + } else { + this._Popcorn.pause(); + } +}; + IriSP.PlayerWidget.prototype.muteHandler = function() { if (!this._Popcorn.muted()) { this._Popcorn.mute(true);