3

I'm trying to adapt the cassette tape demo to play multiple files from external button links. I've managed to get the files to load but because I'm using the default 's' variable in soundManager.createSound() I can only control the last sound in my list with the pause/forward/backwards controls & I need to be able to control the current sound playing.

I was thinking if I could somehow 'get' the id of the current sound playing I could then assign that variable to those controls. Here's what I have in part of the cassette-tape-ui.js:

if (soundManager.ok()) {

s = soundManager.createSound({
  url: "http://www.mysite.co.uk/sounds/sound1.mp3",
  id: "sound1",
  multiShot: false,
  whileplaying: function() {
    for (var i=tapeUIs.length; i--;) {
      // console.log(this.position, this.durationEstimate);
      tapeUIs[i].setProgress(this.position/this.durationEstimate);
    }
  },
  onplay: genericStart,
  onfinish: genericStop,
  onpause: genericStop,
  onresume: genericStart
});
s = soundManager.createSound({
  url: "http://www.mysite.co.uk/sounds/sound2.mp3",
  id: "sound2",
  multiShot: false,
  whileplaying: function() {
    for (var i=tapeUIs.length; i--;) {
      // console.log(this.position, this.durationEstimate);
      tapeUIs[i].setProgress(this.position/this.durationEstimate);
    }
  },
  onplay: genericStart,
  onfinish: genericStop,
  onpause: genericStop,
  onresume: genericStart
});

}

Thanks for any advise in advance.

deeve
  • 113
  • 6

0 Answers0