Skip to content

Commit 1aaa39f

Browse files
Eric WahlforssEric Wahlforss
authored andcommitted
update to latest soundmanager, auto-stopping of players when playing in another player on the same page
1 parent eb61dea commit 1aaa39f

4 files changed

Lines changed: 174 additions & 79 deletions

File tree

demo.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
soundManager.flashVersion = 9;
22
soundManager.debugMode = false; // disable debug mode
33
soundManager.defaultOptions.multiShot = false;
4-
soundManager.url = 'http://a1.soundcloud.com/swf/soundmanager2_flash9.swf'; // change to '.' to use local non-crossdomain soundmanager
4+
soundManager.url = '.'; // change to '.' to use local non-crossdomain soundmanager
55

66
$(function() {
77
$("a.soundcloud-player#basic").scPlayer();

player.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,13 @@
8787
progressBar.click(function(ev) {
8888
var percent = (ev.clientX-progressBar.offset().left)/(progressBar.width());
8989
if(sound.durationEstimate*percent < sound.duration) {
90-
sound.setPosition(sound.durationEstimate*percent);
9190
play();
91+
sound.setPosition(sound.durationEstimate*percent);
9292
}
9393
});
9494

9595
var timer = setInterval(function() { // this is kind of ugly but don't know a better way of waiting for SoundManager 2 when multiple players are on the page
96-
if(window.soundManager.swfLoaded) {
96+
if(soundManager.swfLoaded) {
9797
sound = soundManager.createSound({
9898
id: track.id,
9999
url: track.stream_url,
@@ -111,9 +111,12 @@
111111
},
112112
onload : function () {
113113
loading.css('width',"100%");
114+
},
115+
onstop : function() {
116+
stop();
114117
}
115118
});
116-
119+
117120
if(autoplay) {
118121
play();
119122
}
@@ -138,6 +141,7 @@
138141

139142
var play = function() {
140143
if(sound) {
144+
soundManager.stopAll();
141145
sound.paused ? sound.resume() : sound.play();
142146
$(".delimiter",dom).show();
143147
dom.addClass("playing");

0 commit comments

Comments
 (0)