-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.dart
57 lines (40 loc) · 1.28 KB
/
index.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#import('dart:html');
#import('dart:core');
#source('Sound.dart');
#source('Buzz.dart');
void main() {
var sounds = ['ding.wav', 'song.ogg', 'truck.ogg'];
String base_selected;
Sound soundLeft, soundRight;
void toggle(String side) {
switch(side) {
case 'left':
if (soundLeft != null) {
soundLeft.togglePlay();
}
break;
case 'right':
if (soundRight != null) {
soundRight.togglePlay();
}
break;
}
}
sounds.forEach((s) {
var element = new Element.html('<div class="sound_item">$s</div>');
element.on.click.add((e) {
if (base_selected == 'left') {
soundLeft = new Sound(['sounds/${e.target.text}']);
soundLeft.play();
}
else if (base_selected == 'right') {
soundRight = new Sound(['sounds/${e.target.text}']);
}
});
document.query("#sound_list").nodes.add(element);
});
document.query("#left_base").on.click.add((e) { base_selected = 'left'; } );
document.query("#right_base").on.click.add((e) { base_selected = 'right'; } );
document.query("#left_toggle").on.click.add((e) { toggle('left'); } );
document.query("#right_toggle").on.click.add((e) { toggle('right'); } );
}