diff options
| author | Aaron Perley <aaron.perley@gmail.com> | 2016-10-17 14:54:06 -0400 |
|---|---|---|
| committer | Aaron Perley <aaron.perley@gmail.com> | 2016-10-17 14:54:06 -0400 |
| commit | 1b0d46151bb6e0d98787fa1cdcc3b5b80b7d2478 (patch) | |
| tree | 6653e7e6614eb14fa6dea4e3b90b922275903a63 /webapp/app | |
| parent | ebda59b316159f7e568c634cc5d906447928f973 (diff) | |
| download | bridge-1b0d46151bb6e0d98787fa1cdcc3b5b80b7d2478.tar.zst | |
Add sound effects
Diffstat (limited to 'webapp/app')
| -rw-r--r-- | webapp/app/static/boat.mp3 | bin | 0 -> 28170 bytes | |||
| -rw-r--r-- | webapp/app/static/dolphin.mp3 | bin | 0 -> 25274 bytes | |||
| -rw-r--r-- | webapp/app/static/dory.mp3 | bin | 0 -> 38786 bytes | |||
| -rw-r--r-- | webapp/app/static/eel.mp3 | bin | 0 -> 38786 bytes | |||
| -rw-r--r-- | webapp/app/static/jellyfish.mp3 | bin | 0 -> 23484 bytes | |||
| -rw-r--r-- | webapp/app/static/music.html | 106 | ||||
| -rw-r--r-- | webapp/app/static/nemo.mp3 | bin | 0 -> 38786 bytes | |||
| -rw-r--r-- | webapp/app/static/ocean_waves.mp3 | bin | 0 -> 772254 bytes | |||
| -rw-r--r-- | webapp/app/static/seashore.mp3 | bin | 0 -> 78219 bytes | |||
| -rw-r--r-- | webapp/app/static/shark.mp3 | bin | 0 -> 38786 bytes | |||
| -rw-r--r-- | webapp/app/static/stingray.mp3 | bin | 0 -> 38786 bytes | |||
| -rw-r--r-- | webapp/app/static/underwater.mp3 | bin | 0 -> 178536 bytes | |||
| -rw-r--r-- | webapp/app/static/whale.mp3 | bin | 0 -> 37902 bytes | |||
| -rw-r--r-- | webapp/app/views.py | 23 |
14 files changed, 128 insertions, 1 deletions
diff --git a/webapp/app/static/boat.mp3 b/webapp/app/static/boat.mp3 Binary files differnew file mode 100644 index 0000000..eddcd2c --- /dev/null +++ b/webapp/app/static/boat.mp3 diff --git a/webapp/app/static/dolphin.mp3 b/webapp/app/static/dolphin.mp3 Binary files differnew file mode 100644 index 0000000..41fb75d --- /dev/null +++ b/webapp/app/static/dolphin.mp3 diff --git a/webapp/app/static/dory.mp3 b/webapp/app/static/dory.mp3 Binary files differnew file mode 100644 index 0000000..cbce21d --- /dev/null +++ b/webapp/app/static/dory.mp3 diff --git a/webapp/app/static/eel.mp3 b/webapp/app/static/eel.mp3 Binary files differnew file mode 100644 index 0000000..cbce21d --- /dev/null +++ b/webapp/app/static/eel.mp3 diff --git a/webapp/app/static/jellyfish.mp3 b/webapp/app/static/jellyfish.mp3 Binary files differnew file mode 100644 index 0000000..21ff687 --- /dev/null +++ b/webapp/app/static/jellyfish.mp3 diff --git a/webapp/app/static/music.html b/webapp/app/static/music.html new file mode 100644 index 0000000..154e519 --- /dev/null +++ b/webapp/app/static/music.html @@ -0,0 +1,106 @@ +<!DOCTYPE html> +<html lang="en"> + <head> + </head> + <body> + <audio id="ocean_waves" controls loop> + <source src="/static/ocean_waves.mp3" type="audio/mpeg"> + </audio> + + <audio id="seashore" controls loop> + <source src="/static/seashore.mp3" type="audio/mpeg"> + </audio> + + <audio id="underwater" controls loop> + <source src="/static/underwater.mp3" type="audio/mpeg"> + </audio> + + + <audio id="jellyfish" controls> + <source src="/static/jellyfish.mp3" type="audio/mpeg"> + </audio> + + <audio id="dolphin" controls> + <source src="/static/dolphin.mp3" type="audio/mpeg"> + </audio> + + <audio id="boat" controls> + <source src="/static/boat.mp3" type="audio/mpeg"> + </audio> + + <audio id="nemo" controls> + <source src="/static/nemo.mp3" type="audio/mpeg"> + </audio> + + <audio id="dory" controls> + <source src="/static/dory.mp3" type="audio/mpeg"> + </audio> + + <audio id="whale" controls> + <source src="/static/whale.mp3" type="audio/mpeg"> + </audio> + + <audio id="eel" controls> + <source src="/static/eel.mp3" type="audio/mpeg"> + </audio> + + <audio id="stingray" controls> + <source src="/static/stingray.mp3" type="audio/mpeg"> + </audio> + + <audio id="shark" controls> + <source src="/static/shark.mp3" type="audio/mpeg"> + </audio> + + <script type="text/javascript" src="//code.jquery.com/jquery-2.1.4.min.js"></script> + <script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/socket.io/1.3.5/socket.io.min.js"></script> + + <script> + var currently_playing = undefined; + function playBackground(id) { + new_playing = document.getElementById(id) + if( !new_playing ) { + return; + } + + if (currently_playing && currently_playing != new_playing) { + currently_playing.pause(); + } + currently_playing = new_playing; + currently_playing.play(); + } + + function playEffect(id) { + document.getElementById(id).play(); + } + + $(document).ready(function() { + var namespace = '/music'; + socket = io.connect('http://' + document.domain + ':' + location.port + namespace); + + socket.on('connect', function() { + console.log('connected!'); + }); + + socket.on('disconnect', function() { + console.log('disconnected'); + }); + + + socket.on('background', function(msg) { + console.log('background', msg); + playBackground(msg.id); + }); + + socket.on('effect', function(msg) { + playEffect(msg.id); + }); + + socket.emit('ready'); + setInterval(function() { + socket.emit('ready'); + }, 5000); + }); + </script> + </body> +</html> diff --git a/webapp/app/static/nemo.mp3 b/webapp/app/static/nemo.mp3 Binary files differnew file mode 100644 index 0000000..cbce21d --- /dev/null +++ b/webapp/app/static/nemo.mp3 diff --git a/webapp/app/static/ocean_waves.mp3 b/webapp/app/static/ocean_waves.mp3 Binary files differnew file mode 100644 index 0000000..5bd95c4 --- /dev/null +++ b/webapp/app/static/ocean_waves.mp3 diff --git a/webapp/app/static/seashore.mp3 b/webapp/app/static/seashore.mp3 Binary files differnew file mode 100644 index 0000000..8c86694 --- /dev/null +++ b/webapp/app/static/seashore.mp3 diff --git a/webapp/app/static/shark.mp3 b/webapp/app/static/shark.mp3 Binary files differnew file mode 100644 index 0000000..cbce21d --- /dev/null +++ b/webapp/app/static/shark.mp3 diff --git a/webapp/app/static/stingray.mp3 b/webapp/app/static/stingray.mp3 Binary files differnew file mode 100644 index 0000000..cbce21d --- /dev/null +++ b/webapp/app/static/stingray.mp3 diff --git a/webapp/app/static/underwater.mp3 b/webapp/app/static/underwater.mp3 Binary files differnew file mode 100644 index 0000000..e387380 --- /dev/null +++ b/webapp/app/static/underwater.mp3 diff --git a/webapp/app/static/whale.mp3 b/webapp/app/static/whale.mp3 Binary files differnew file mode 100644 index 0000000..9c03e75 --- /dev/null +++ b/webapp/app/static/whale.mp3 diff --git a/webapp/app/views.py b/webapp/app/views.py index a13bf12..99c57c3 100644 --- a/webapp/app/views.py +++ b/webapp/app/views.py @@ -16,6 +16,19 @@ def send_static(path): connections = set() +@sio.on('connect', namespace='/music') +def connect_music(sid, environ): + print("connect_music", sid) + +@sio.on('disconnect', namespace='/music') +def disconnect_music(sid): + print("disconnect_music", sid) + +current_background_music = None +@sio.on('ready', namespace='/music') +def ready_music(sid): + sio.emit('background', {'id': current_background_music}, room=sid, namespace='/music') + @sio.on('connect', namespace='/spawn') def connect(sid, environ): print("connect ", sid) @@ -25,6 +38,7 @@ def connect(sid, environ): def message(sid, data): print("message ", data) send_queue.put(('spawn', data)) + sio.emit('effect', {'id': data['type']}, namespace='/music'); @sio.on('ready', namespace='/spawn') def ready(sid): @@ -52,10 +66,17 @@ def recv_events(): event = recv_queue.get() if event[0] == 'enable image': fish_state[event[1]['name']] = 1 + sio.emit('fish state', fish_state, namespace='/spawn') elif event[0] == 'disable image': fish_state[event[1]['name']] = 0 + sio.emit('fish state', fish_state, namespace='/spawn') + elif event[0] == 'background music': + print "****** background music ", event[1] + sio.emit('background', {'id': event[1]}, namespace='/music'); + current_background_music = event[1]; + elif event[0] == 'effect music': + sio.emit('effect', {'id': event[1]}, namespace='/music'); - sio.emit('fish state', fish_state, namespace='/spawn') thread = sio.start_background_task(recv_events) |
