From efdab32aa84c1aeae23e7eeda6b52f25a50aa13a Mon Sep 17 00:00:00 2001 From: calzoneman Date: Sat, 26 Mar 2016 11:25:04 -0700 Subject: [PATCH] soundcloud: fix volume preservation Soundcloud requires rebinding the READY event when a new track is loaded in order to set the volume. --- player/soundcloud.coffee | 3 +++ www/js/player.js | 7 ++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/player/soundcloud.coffee b/player/soundcloud.coffee index 75261a5a..bb072d07 100644 --- a/player/soundcloud.coffee +++ b/player/soundcloud.coffee @@ -69,6 +69,9 @@ window.SoundCloudPlayer = class SoundCloudPlayer extends Player else soundUrl = data.id @soundcloud.load(soundUrl, auto_play: true) + @soundcloud.bind(SC.Widget.Events.READY, => + @setVolume(VOLUME) + ) else console.error('SoundCloudPlayer::load() called but soundcloud is not ready') diff --git a/www/js/player.js b/www/js/player.js index 7974fcb3..b7f6ac24 100644 --- a/www/js/player.js +++ b/www/js/player.js @@ -771,9 +771,14 @@ } else { soundUrl = data.id; } - return this.soundcloud.load(soundUrl, { + this.soundcloud.load(soundUrl, { auto_play: true }); + return this.soundcloud.bind(SC.Widget.Events.READY, (function(_this) { + return function() { + return _this.setVolume(VOLUME); + }; + })(this)); } else { return console.error('SoundCloudPlayer::load() called but soundcloud is not ready'); }