@@ -6,10 +6,11 @@ if(!javaxt.dhtml) javaxt.dhtml={};
66//******************************************************************************
77/**
88 * Used to render a slider that can be used a part of a audio or video
9- * controller. Provides basic functions like play, pause, and stop. Users
10- * can interact with the slider while its running and get back elapsed time.
11- * This class requires the javaxt.dhtml.Slider class which, in turn requires
12- * a css file but has no other dependencies.
9+ * controller. This class builds upon the javaxt.dhtml.Slider class by
10+ * providing basic functions like play, pause, and stop. However, this class
11+ * does not provide any buttons or any other components to perform these
12+ * operations - this is just a fancy slider :-) Users can interact with the
13+ * slider while its running and get back elapsed time.
1314 *
1415 ******************************************************************************/
1516
@@ -23,20 +24,35 @@ javaxt.dhtml.PlayControl = function(parent, config) {
2324 var loop = false ;
2425
2526 var defaultConfig = {
26- startTime : 0 , //seconds
27- speed : 0.2 , //seconds
28- totalTime : 60 , //seconds
27+
28+ /** Used to specify the start time, in seconds. Default is 0.
29+ */
30+ startTime : 0 ,
31+
32+
33+ /** Refresh rate, in seconds. Default is 0.2.
34+ */
35+ speed : 0.2 ,
36+
37+
38+ /** Used to specify the total run time, in seconds. Default is 60.
39+ */
40+ totalTime : 60 ,
41+
42+
43+ /** Style for individual elements within the component. Uses the style
44+ * defined in the javaxt.dhtml.Slider class by default.
45+ */
2946 style : {
30- groove : "sliderGrove" ,
31- handle : "sliderHandle"
47+ groove : { } ,
48+ handle : { }
3249 }
3350 } ;
3451
3552
3653 //**************************************************************************
3754 //** Constructor
3855 //**************************************************************************
39-
4056 var init = function ( ) {
4157
4258 //Clone the config so we don't modify the original config object
@@ -75,7 +91,9 @@ javaxt.dhtml.PlayControl = function(parent, config) {
7591 //**************************************************************************
7692 //** setRunTime
7793 //**************************************************************************
78- /** @param runTime in seconds
94+ /** Used to update the total run time. This value is originally set in the
95+ * config settings (see totalTime).
96+ * @param runTime Total run time, in seconds
7997 */
8098 this . setRunTime = function ( runTime ) {
8199 if ( runTime === config . totalTime ) return ;
@@ -92,6 +110,8 @@ javaxt.dhtml.PlayControl = function(parent, config) {
92110 //**************************************************************************
93111 //** play
94112 //**************************************************************************
113+ /** Used to start the player
114+ */
95115 this . play = function ( _loop ) {
96116 if ( playing === true ) return ;
97117
@@ -102,7 +122,7 @@ javaxt.dhtml.PlayControl = function(parent, config) {
102122
103123 playing = true ;
104124 var startDate = new Date ( ) . getTime ( ) ;
105- var currVal = slider . getValue ( ) ;
125+ var currVal = slider . getPosition ( ) ;
106126 if ( currVal > 0 ) {
107127 startDate = startDate - ( ( currVal / slider . getWidth ( ) ) * config . totalTime ) * 1000 ;
108128 }
@@ -138,6 +158,8 @@ javaxt.dhtml.PlayControl = function(parent, config) {
138158 //**************************************************************************
139159 //** pause
140160 //**************************************************************************
161+ /** Used to pause the player.
162+ */
141163 this . pause = function ( ) {
142164 clearInterval ( timerId ) ;
143165 playing = false ;
@@ -147,6 +169,8 @@ javaxt.dhtml.PlayControl = function(parent, config) {
147169 //**************************************************************************
148170 //** stop
149171 //**************************************************************************
172+ /** Used to stop the player and set the start time to 0 seconds.
173+ */
150174 this . stop = function ( ) {
151175 me . pause ( ) ;
152176 slider . setValue ( 0 ) ;
@@ -156,6 +180,8 @@ javaxt.dhtml.PlayControl = function(parent, config) {
156180 //**************************************************************************
157181 //** isPlaying
158182 //**************************************************************************
183+ /** Returns true if the player is playing.
184+ */
159185 this . isPlaying = function ( ) {
160186 return playing ;
161187 } ;
@@ -165,13 +191,16 @@ javaxt.dhtml.PlayControl = function(parent, config) {
165191 //** getElapsedTime
166192 //**************************************************************************
167193 this . getElapsedTime = function ( ) {
168- return ( slider . getValue ( ) / slider . getWidth ( ) ) * config . totalTime ;
194+ return ( slider . getPosition ( ) / slider . getWidth ( ) ) * config . totalTime ;
169195 } ;
170196
171197
172198 //**************************************************************************
173199 //** setElapsedTime
174200 //**************************************************************************
201+ /** Used to update the elapsed time time.
202+ * @param elapsedTime Time in seconds
203+ */
175204 this . setElapsedTime = function ( elapsedTime ) {
176205 if ( elapsedTime == null || elapsedTime < 0 ) return ;
177206
@@ -183,32 +212,31 @@ javaxt.dhtml.PlayControl = function(parent, config) {
183212 if ( x > w ) x = 0 ;
184213
185214
186-
187215 slider . setValue ( x ) ;
188-
189216 } ;
190217
191218
192219 //**************************************************************************
193220 //** onChange
194221 //**************************************************************************
222+ /** Called whenever the player is updated.
223+ */
195224 this . onChange = function ( elapsedTime ) { } ;
196225
197226
198227 //**************************************************************************
199228 //** onEnd
200229 //**************************************************************************
230+ /** Called whenever the elapsed time equals the total run time.
231+ */
201232 this . onEnd = function ( ) { } ;
202233
203234
204-
205-
206235 //**************************************************************************
207236 //** Utils
208237 //**************************************************************************
209238 var merge = javaxt . dhtml . utils . merge ;
210239
211240
212241 init ( ) ;
213-
214242} ;
0 commit comments