]>
Commit | Line | Data |
---|---|---|
1 | qwebirc.sound.SoundPlayer = new Class({ | |
2 | Implements: [Events], | |
3 | initialize: function() { | |
4 | var sb = qwebirc.global.staticBaseURL; | |
5 | if(qwebirc.global.baseURL.substr(qwebirc.global.baseURL.length - 1, 1) == "/" && sb.substr(0, 1) == "/") | |
6 | sb = sb.substr(1); | |
7 | ||
8 | this.sounds = {}; | |
9 | this.soundURL = qwebirc.global.baseURL + sb + "sound/"; | |
10 | }, | |
11 | play: function(url) { | |
12 | try { | |
13 | var s = this.sounds[url]; | |
14 | if (!s) | |
15 | s = this.sounds[url] = new Audio(this.soundURL + url); | |
16 | s.play(); | |
17 | } catch(e) { | |
18 | /* we tried */ | |
19 | } | |
20 | } | |
21 | }); |