File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -118,6 +118,17 @@ var handleMatchTime = function(data) {
118
118
} ) ;
119
119
} ;
120
120
121
+
122
+ // Handles a websocket message to play a sound to signal match start/stop/etc.
123
+ const handlePlaySound = function ( sound ) {
124
+ $ ( "audio" ) . each ( function ( k , v ) {
125
+ // Stop and reset any sounds that are still playing.
126
+ v . pause ( ) ;
127
+ v . currentTime = 0 ;
128
+ } ) ;
129
+ $ ( "#sound-" + sound ) [ 0 ] . play ( ) ;
130
+ } ;
131
+
121
132
// Handles a websocket message to update the match score.
122
133
var handleRealtimeScore = function ( data ) {
123
134
$ ( "#redScore" ) . text (
@@ -140,6 +151,7 @@ $(function() {
140
151
matchLoad : function ( event ) { handleMatchLoad ( event . data ) ; } ,
141
152
matchTime : function ( event ) { handleMatchTime ( event . data ) ; } ,
142
153
matchTiming : function ( event ) { handleMatchTiming ( event . data ) ; } ,
143
- realtimeScore : function ( event ) { handleRealtimeScore ( event . data ) ; }
154
+ realtimeScore : function ( event ) { handleRealtimeScore ( event . data ) ; } ,
155
+ playSound : function ( event ) { handlePlaySound ( event . data ) ; }
144
156
} ) ;
145
157
} ) ;
Original file line number Diff line number Diff line change 39
39
< script src ="/static/js/cheesy-websocket.js "> </ script >
40
40
< script src ="/static/js/match_timing.js "> </ script >
41
41
< script src ="/static/js/alliance_station_display.js "> </ script >
42
+ {{range $sound := .MatchSounds}}
43
+ < audio id ="sound-{{$sound.Name}} " src ="/static/audio/{{$sound.Name}}.{{$sound.FileExtension}} " preload ="auto ">
44
+ </ audio >
45
+ {{end}}
42
46
</ body >
43
47
</ html >
You can’t perform that action at this time.
0 commit comments