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 trace
("soundComplete");
45 trace
("Loading sound "+urlin
.getText
()+". Streaming ? "+streamingcb
.checked
());
46 mySound
.loadSound
(urlin
.getText
(), streamingcb
.checked
());
51 var off
= offIn
.getText
();
52 var loops
= loopsIn
.getText
();
53 trace
("Starting sound at seconds offset "+off
+" with loop count "+loops
);
54 mySound
.start
(off
, loops
); // <startSecs>, <nLoops>
59 trace
("Stopping sound.");
63 s_getposition
= function() {
64 //trace("s_getposition called, position is "+mySound.position);
65 return mySound
.position
+"/"+mySound
.duration
;
70 trace
("Pausing sound (basically recording current position in offset and stopping.");
71 offIn
.setText
( mySound
.position
);
75 streamingcb
= new Checkbox
(_root
, "Streaming");
76 urlin
= new Input
(_root
, "URL");
78 if ( typeof(url
) == 'undefined' ) url
= 'easysound.mp3';
81 offIn
= new Input
(_root
, "Offsets seconds");
85 loopsIn
= new Input
(_root
, "Loops");
87 loopsIn
.moveTo
(300, 30);
89 loadbtn
= new Button(_root
, "Load", s_load
);
90 loadbtn
.moveTo
(0, 60);
92 startbtn
= new Button(_root
, "Start", s_start
);
93 startbtn
.moveTo
(50, 60);
96 pausbtn = new Button(_root, "Pause", s_pause);
97 pausbtn.moveTo(100, 60);
100 stopbtn
= new Button(_root
, "Stop", s_stop
);
101 stopbtn
.moveTo
(100, 60);
103 infoPosition
= new InfoLine
(_root
, "position", s_getposition
);
104 infoPosition
.moveTo
(0, 120);