freaktechnik

ngale playpausestop

May 30th, 2012
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
XML 2.79 KB | None | 0 0
  1.         <xul:button type="sb-clickhold"
  2.                 id="sb-player-stop-button-stop"
  3.                 sbid="stop"
  4.                 class="sb-player-stop-button-stop sb-player-button"
  5.                 oncommand="onPlayPause(event.target);"
  6.                 delayDuration="2000"
  7.                 tooltiptext="&tooltip.control.stop;"
  8.                 xbl:inherits="label,position,disabled"
  9.                 onmenushowing="syncMenus();">
  10.           <xul:menupopup xbl:inherits="popupanchor,popupalign">
  11.               <xul:menuitem id="menu_play" class="menuitem-iconic" label="&menu.control.play.button;"/>
  12.               <xul:menuitem id="menu_pause" class="menuitem-iconic" label="&menu.control.pause.button;"/>
  13.               <xul:menuitem id="menu_stop" class="menuitem-iconic" label="&menu.control.stop.button;"/>
  14.             </xul:menupopup>
  15.         </xul:button>
  16.  
  17.       </xul:hbox>
  18.     </content>
  19.  
  20.   <implementation>
  21.  
  22.     <constructor>
  23.       <![CDATA[
  24.        // observer for DataRemote
  25.        this.on_state_change = {
  26.          _that: null,
  27.          observe: function( aSubject, aTopic, aData ) { this._that.onStateChanged(); }
  28.        };
  29.        this.on_state_change._that = this;
  30.        this.remote_playing = SB_NewDataRemote("faceplate.playing", null);
  31.        this.remote_paused = SB_NewDataRemote("faceplate.paused", null);
  32.        this.remote_playing.bindObserver(this.on_state_change, false);
  33.        this.remote_paused.bindObserver(this.on_state_change, false);
  34.         this.remote_length = SBDataBindElementAttribute( "metadata.length", this, "maxpos" );
  35.      ]]>
  36.     </constructor>
  37.     <destructor>
  38.       <![CDATA[
  39.        this.remote_playing.unbind();
  40.        this.remote_paused.unbind();
  41.         this.remote_length.unbind();
  42.      ]]>
  43.     </destructor>
  44.  
  45.     <field name="play">document.getAnonymousElementByAttribute(this, 'sbid', 'play');</field>
  46.     <field name="pause">document.getAnonymousElementByAttribute(this, 'sbid', 'pause');</field>
  47.     <field name="stop">document.getAnonymousElementByAttribute(this, 'sbid', 'stop');</field>
  48.     <field name="len">0</field>
  49.     <property name="maxpos">
  50.      <getter>
  51.         return this.len;
  52.      </getter>
  53.      <setter>
  54.         this.len = val;
  55.         this.onStateChanged();
  56.      </setter>
  57.     </property>
  58.  
  59.     <method name="onStateChanged">
  60.       <body>
  61.         <![CDATA[
  62.          if (this.remote_playing.boolValue && !this.remote_paused.boolValue && this.maxpos > 0) {
  63.            this.play.hidden = true;
  64.             this.stop.hidden = true;
  65.            this.pause.hidden = false;
  66.           } else if (this.remote_playing.boolValue && this.maxpos == 0) {
  67.             this.play.hidden = true;
  68.            this.stop.hidden = false;
  69.            this.pause.hidden = true;
  70.           } else {
  71.            this.play.hidden = false;
  72.            this.stop.hidden = true;
  73.            this.pause.hidden = true;
  74.          }
  75.        ]]>
  76.       </body>
  77.     </method>
Advertisement
Add Comment
Please, Sign In to add comment