1 /***********************************************************************
3 * Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 ***********************************************************************
22 * Simple sound test. Can load (streaming or not) and start/stop.
24 * Initial author: Sandro Santilli <strk@keybit.net>
26 ***********************************************************************/
30 if ( !hasOwnProperty
('url') )
32 trace
("No 'url' passed in querystring, using 'easysound.mp3'");
36 mySound
= new Sound();
38 mySound
.onSoundComplete
= function()
40 var s
= 'onSoundComplete(';
41 for (var i
=0; i
<arguments.length
; ++i
) {
49 mySound
.onLoad
= function(success
)
52 for (var i
=0; i
<arguments.length
; ++i
) {
62 trace
("Loading sound "+urlin
.getText
()+". Streaming ? "+streamingcb
.checked
());
63 mySound
.loadSound
(urlin
.getText
(), streamingcb
.checked
());
68 var off
= offIn
.getText
();
69 var loops
= loopsIn
.getText
();
70 trace
("Starting sound at seconds offset "+off
+" with loop count "+loops
);
71 mySound
.start
(off
, loops
); // <startSecs>, <nLoops>
76 trace
("Stopping sound.");
80 s_getposition
= function() {
81 //trace("s_getposition called, position is "+mySound.position);
82 return mySound
.position
+"/"+mySound
.duration
;
87 trace
("Pausing sound (basically recording current position in offset and stopping.");
88 offIn
.setText
( mySound
.position
);
92 streamingcb
= new Checkbox
(_root
, "Streaming");
93 urlin
= new Input
(_root
, "URL");
95 if ( typeof(url
) == 'undefined' ) url
= 'easysound.mp3';
98 offIn
= new Input
(_root
, "Offsets seconds");
102 loopsIn
= new Input
(_root
, "Loops");
104 loopsIn
.moveTo
(300, 30);
106 loadbtn
= new Button(_root
, "Load", s_load
);
107 loadbtn
.moveTo
(0, 60);
109 startbtn
= new Button(_root
, "Start", s_start
);
110 startbtn
.moveTo
(50, 60);
113 pausbtn = new Button(_root, "Pause", s_pause);
114 pausbtn.moveTo(100, 60);
117 stopbtn
= new Button(_root
, "Stop", s_stop
);
118 stopbtn
.moveTo
(100, 60);
120 infoPosition
= new InfoLine
(_root
, "position", s_getposition
);
121 infoPosition
.moveTo
(0, 120);