root / trunk / web / dojo / dojox / av / widget / PlayButton.js @ 9
History | View | Annotate | Download (1.35 KB)
1 |
/*
|
---|---|
2 |
Copyright (c) 2004-2010, The Dojo Foundation All Rights Reserved.
|
3 |
Available via Academic Free License >= 2.1 OR the modified BSD license.
|
4 |
see: http://dojotoolkit.org/license for details
|
5 |
*/
|
6 |
|
7 |
|
8 |
if(!dojo._hasResource["dojox.av.widget.PlayButton"]){ |
9 |
dojo._hasResource["dojox.av.widget.PlayButton"]=true; |
10 |
dojo.provide("dojox.av.widget.PlayButton");
|
11 |
dojo.require("dijit._Widget");
|
12 |
dojo.require("dijit._Templated");
|
13 |
dojo.require("dijit.form.Button");
|
14 |
dojo.declare("dojox.av.widget.PlayButton",[dijit._Widget,dijit._Templated],{templateString:dojo.cache("dojox.av.widget","resources/PlayButton.html","<div class=\"PlayPauseToggle Pause\" dojoAttachEvent=\"click:onClick\">\n <div class=\"icon\"></div>\n</div>\n"),postCreate:function(){ |
15 |
this.showPlay();
|
16 |
},setMedia:function(_1){ |
17 |
this.media=_1;
|
18 |
dojo.connect(this.media,"onEnd",this,"showPlay"); |
19 |
dojo.connect(this.media,"onStart",this,"showPause"); |
20 |
},onClick:function(){ |
21 |
if(this._mode=="play"){ |
22 |
this.onPlay();
|
23 |
}else{
|
24 |
this.onPause();
|
25 |
} |
26 |
},onPlay:function(){ |
27 |
if(this.media){ |
28 |
this.media.play();
|
29 |
} |
30 |
this.showPause();
|
31 |
},onPause:function(){ |
32 |
if(this.media){ |
33 |
this.media.pause();
|
34 |
} |
35 |
this.showPlay();
|
36 |
},showPlay:function(){ |
37 |
this._mode="play"; |
38 |
dojo.removeClass(this.domNode,"Pause"); |
39 |
dojo.addClass(this.domNode,"Play"); |
40 |
},showPause:function(){ |
41 |
this._mode="pause"; |
42 |
dojo.addClass(this.domNode,"Pause"); |
43 |
dojo.removeClass(this.domNode,"Play"); |
44 |
}}); |
45 |
} |