Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var SoundPlayer;
- window.Host && window.Host.Sound ? (Host.Log("Using SoundPlayer!"), SoundPlayer = function(t) {
- function e(t, e) {
- return r[t] = new i(t, e)
- }
- function i(e, i) {
- var r = this;
- r.playing = !1;
- var o = i;
- this.resetGain = function() {
- this.setGain(i)
- }, this.setGain = function(t) {
- o = t, Host.Sound.SetVolume(e, t)
- }, this.play = function(i, a) {
- function s() {
- Host.Sound.Play(e, e, a, o, t)
- }
- n.muted || t && r.playing || (r.playing = !0, i ? setTimeout(s, 1e3 * i) : s())
- }, this.stop = function(t) {
- r.playing = !1, Host.Sound.Stop(e)
- }
- }
- t = t ? !0 : !1;
- var r = [],
- n = this;
- this.muted = !1, this.setMuted = function(t) {
- n.muted = t
- }, this.get = function(i, n) {
- return Host.Sound.Preload(i, i, t), r[i] || e(i, n)
- }
- }) : SoundPlayer = function(t) {
- function e() {
- h = !0, s.length && s.shift().send()
- }
- function i(i, r) {
- function a(t, e) {
- if (!o.muted && d.loaded) {
- p = {
- stop: function() {}
- };
- try {
- d.playing = !0, p = n.createBufferSource(), p.buffer = l, p.loop = e || !1, d.resetGain(), p.connect(c), c.connect(n.destination), p.start(n.currentTime + (t || 0))
- } catch (i) {}
- return p
- }
- }
- var l, d = this;
- d.targetGain = r, d.loaded = !1, d.playing = !1;
- var c = {
- gain: {
- value: 0
- }
- };
- if (n) {
- var u = new XMLHttpRequest;
- u.open("GET", vpath + i, !0), u.responseType = "arraybuffer", u.onload = function() {
- e(), n.decodeAudioData(u.response, function(t) {
- l = t, d.loaded = !0
- })
- }, s.push(u), h || (e(), t || e()), c = n.createGain ? n.createGain() : {
- gain: {
- value: 1
- }
- }
- }
- this.gain = c.gain, this.setGain = function(t) {
- this.gain.value = t
- }, this.resetGain = function() {
- this.gain.value = r
- };
- var p = void 0;
- this.play = function(e, i) {
- if (d.loaded) {
- if (t) {
- if (d.playing) return
- } else d.stop(0);
- a(e, i)
- }
- }, this.stop = function(t) {
- if (p && d.playing) try {
- p.stop(t)
- } catch (e) {}
- d.playing = !1
- }
- }
- function r(t, e) {
- return a[t] = new i(t, e)
- }
- var n, o = this;
- (window.AudioContext || window.webkitAudioContext) && (SoundPlayer.context = n = SoundPlayer.context || new(window.AudioContext || window.webkitAudioContext));
- var a = [];
- this.muted = !1, this.setMuted = function(t) {
- o.muted = t
- }, this.get = function(t, e) {
- return a[t] || r(t, e)
- };
- var s = [],
- h = !1;
- this.currentTrack = null
- }, SoundPlayer.unblocked = !1, window.Sound = new SoundPlayer, window.Music = new SoundPlayer(!0), window.backgroundMusic = null, window.clickSound = null, window.remoteConfig = {};
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement