-
Notifications
You must be signed in to change notification settings - Fork 710
/
sound.js
238 lines (223 loc) · 7.85 KB
/
sound.js
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
function Sound(source) {
this.tracks = {
'Adversity': {
path: "music/Adversity.mp3",
artist: "Seropard",
title: "Adversity",
url: "https://soundcloud.com/seropard"
},
'Beach Wedding Dance': {
path: "music/Rolemusic_-_07_-_Beach_Wedding_Dance.mp3",
artist: "Rolemusic",
title: "Beach Wedding Dance",
url: "https://soundcloud.com/rolemusic"
},
'BossLoop': {
path: "music/Boss Loop 1.mp3",
artist: "Essa",
title: "Boss Loop 1",
url: "http://www.youtube.com/user/Essasmusic"
},
'Brazil': {
path: "music/Vernon_Lenoir_-_Brazilicon_alley.mp3",
artist: "Vernon Lenoir",
title: "Brazilicon Alley",
url: "http://vernonlenoir.wordpress.com/"
},
'Chip': {
path: "music/ThatAndyGuy-Chip-loop.mp3",
artist: "That Andy Guy",
title: "Da Funk Do You Know 'bout Chip?",
url: "https://soundcloud.com/that-andy-guy"
},
'cloudy_sin': {
path: "music/intricate_cloudy_sin.mp3",
artist: "iNTRICATE",
title: "cloudy sin",
url: "https://soundcloud.com/stk13"
},
'Come and Find Me': {
path: "music/Eric_Skiff_-_09_-_Come_and_Find_Me_-_B_mix.mp3",
artist: "Eric Skiff",
title: "Come and Find Me",
url: "http://ericskiff.com/"
},
'coming soon': {
path: "music/Fex_coming_soon.mp3",
artist: "Fex",
title: "coming soon",
url: "http://artistserver.com/Fex"
},
'Comme Des Orages': {
path: "music/Obsibilo_-_02_-_Comme_Des_Orages.mp3",
artist: "Obsibilo",
title: "Comme Des Orages",
url: "http://freemusicarchive.org/music/Obsibilo/"
},
'conspiracy': {
path: "music/conspiracy_bitcrusher_final.mp3",
artist: "Mike and Alan",
title: "Conspiracy",
url: "https://www.facebook.com/MicAndAlan"
},
'Death Destroyer': {
path: "music/BLEO_-_02_-_Death_Destroyer_Radio_Edit_feat_Rhinostrich.mp3",
artist: "BLEO feat Rhinostrich",
title: "Death Destroyer (Radio Edit)",
url: "http://bleo.dummydrome.com/"
},
'GameScratch': {
path: "music/DmitryMazin-GameScratch.mp3",
artist: "Dmitry Mazin",
title: "Dynamic Punctuality",
url: "https://soundcloud.com/dmitry-mazin"
},
'gurh': {
path: "music/gurh.mp3",
artist: "Dmitry Mazin",
title: "Dmitry's Thing #2",
url: "https://soundcloud.com/dmitry-mazin"
},
'Messeah': {
path: "music/RoccoW_-_Messeah.mp3",
artist: "RoccoW",
title: "Messeah",
url: "https://soundcloud.com/roccow"
},
'Night Owl': {
path: "music/Broke_For_Free_-_01_-_Night_Owl.mp3",
artist: "Broke for Free",
title: "Night Owl",
url: "http://brokeforfree.com/"
},
'Obscure Terrain': {
path: "music/Revolution_Void_-_08_-_Obscure_Terrain.mp3",
artist: "Revolution Void",
title: "Obscure Terrain",
url: "http://revolutionvoid.com/"
},
'Searching': {
path: "music/Eric_Skiff_-_06_-_Searching.mp3",
artist: "Eric Skiff",
title: "Searching",
url: "http://ericskiff.com/"
},
'Slimeball Vomit': {
path: "music/Various_Artists_-_15_-_Slimeball_vomit.mp3",
artist: "Radio Scotvoid",
title: "Slimeball Vomit",
url: "https://soundcloud.com/radio-scotvoid"
},
'Soixante-8': {
path: "music/Obsibilo_-_Soixante-8.mp3",
artist: "Obsibilo",
title: "Soixante-8",
url: "http://freemusicarchive.org/music/Obsibilo/"
},
'Tart': {
path: "music/BLEO_-_02_-_Tart_Pts_1__2_feat_KeFF.mp3",
artist: "BLEO feat KeFF",
title: "Tart (Pts 1-2)",
url: "http://bleo.dummydrome.com/"
},
'The Green': {
path: "music/Yonnie_The_Green.mp3",
artist: "Jonathan Holliday",
title: "The Green",
url: "http://www.soundclick.com/bands/default.cfm?bandID=836578"
},
'The_Waves_Call_Her_Name': {
path: "music/Sycamore_Drive_-_03_-_The_Waves_Call_Her_Name.mp3",
artist: "Sycamore Drive",
title: "The Waves Call Her Name",
url: "http://sycamoredrive.bandcamp.com/"
},
'Y': {
path: "music/Tortue_Super_Sonic_-_11_-_Y.mp3",
artist: "Tortue Super Sonic",
title: "Y",
url: "https://soundcloud.com/tss-tortue-super-sonic"
}
};
this.defaultTracks = [ // (not currently used, as all levels now have explicit tracks)
'GameScratch',
'Y',
'Searching',
'Soixante-8',
'Come and Find Me'
];
this.sources = {
'local': '',
'cloudfront': 'http://dk93t8qfl63bu.cloudfront.net/'
};
this.bgPlayerElt = $("#jquery_bgPlayer");
this.soundPlayerElt = $("#jquery_soundPlayer");
this.muted = false;
this.currentLevelNum = -1;
this.init = function() {
var sound = this;
this.source = this.sources[source];
this.bgPlayerElt.jPlayer({
wmode: "window",
loop: true,
swfPath: "lib/Jplayer.swf",
volume: 0.6
});
this.soundPlayerElt.jPlayer({
wmode: "window",
loop: false,
supplied: 'wav',
swfPath: "lib/Jplayer.swf"
});
$(window).focus(function () {
$(sound.bgPlayerElt).jPlayer('play');
}).blur(function () {
$(sound.bgPlayerElt).jPlayer('pause');
});
};
this.playTrackByName = function (name) {
this.trackForLevel = name;
var track = this.tracks[name];
if (track.url) {
var nowPlayingMsg = 'Now playing: "' + track.title + '" - <a target="_blank" draggable="false" href="' + track.url + '">' + track.artist + '</a>';
} else {
var nowPlayingMsg = 'Now playing: "' + track.title + '" - ' + track.artist;
}
$('#nowPlayingMsg').html(nowPlayingMsg);
if (!this.muted && this.currentlyPlayingTrack !== name) {
var path = this.source + track.path;
$(this.bgPlayerElt).jPlayer('stop');
$(this.bgPlayerElt).jPlayer("setMedia", {
'mp3': path
});
$(this.bgPlayerElt).jPlayer('play');
this.currentlyPlayingTrack = name;
}
};
this.playTrackByNum = function (num) {
this.playTrackByName(this.defaultTracks[(num - 1) % this.defaultTracks.length]);
};
this.playSound = function (name) {
$(this.soundPlayerElt).jPlayer('stop');
$(this.soundPlayerElt).jPlayer("setMedia", {
'wav': 'sound/' + name + '.wav'
});
$(this.soundPlayerElt).jPlayer('play');
};
this.toggleSound = function() {
if (this.muted) {
this.bgPlayerElt.jPlayer('unmute');
this.soundPlayerElt.jPlayer('unmute');
$("#muteButton img").attr('src', 'images/mute-off.png');
this.muted = false;
this.playTrackByName(this.trackForLevel);
} else {
this.bgPlayerElt.jPlayer('mute');
this.soundPlayerElt.jPlayer('mute');
$("#muteButton img").attr('src', 'images/mute-on.png');
this.muted = true;
}
};
// constructor
this.init();
}