source: Dev/trunk/src/client/dojox/av/widget/PlayButton.js

Last change on this file was 483, checked in by hendrikvanantwerpen, 11 years ago

Added Dojo 1.9.3 release.

File size: 1.6 KB
Line 
1define(['dojo', 'dijit', 'dijit/_Widget', 'dijit/_TemplatedMixin'],function(dojo, dijit, _Widget, _TemplatedMixin){
2
3return dojo.declare("dojox.av.widget.PlayButton", [_Widget, _TemplatedMixin], {
4        // summary:
5        //              A Play/Pause button widget to use with dojox.av.widget.Player
6
7        templateString: dojo.cache("dojox.av.widget","resources/PlayButton.html"),
8
9        postCreate: function(){
10                // summary:
11                //              Initialize button.
12                this.showPlay();
13        },
14
15        setMedia: function(/* Object */med){
16                // summary:
17                //              A common method to set the media in all Player widgets.
18                //              May do connections and initializations.
19
20                this.media = med;
21                dojo.connect(this.media, "onEnd", this, "showPlay");
22                dojo.connect(this.media, "onStart", this, "showPause");
23        },
24
25        onClick: function(){
26                // summary:
27                //              Fired on play or pause click.
28
29                if(this._mode=="play"){
30                        this.onPlay();
31                }else{
32                        this.onPause();
33                }
34        },
35
36        onPlay: function(){
37                // summary:
38                //              Fired on play click.
39
40                if(this.media){
41                        this.media.play();
42                }
43                this.showPause();
44        },
45        onPause: function(){
46                // summary:
47                //              Fired on pause click.
48
49                if(this.media){
50                        this.media.pause();
51                }
52                this.showPlay();
53        },
54        showPlay: function(){
55                // summary:
56                //              Toggles the pause button invisible and the play
57                //              button visible..
58
59                this._mode = "play";
60                dojo.removeClass(this.domNode, "Pause");
61                dojo.addClass(this.domNode, "Play");
62        },
63        showPause: function(){
64                // summary:
65                //              Toggles the play button invisible and the pause
66                //              button visible.
67
68                this._mode = "pause";
69                dojo.addClass(this.domNode, "Pause");
70                dojo.removeClass(this.domNode, "Play");
71        }
72});
73
74});
Note: See TracBrowser for help on using the repository browser.