Jump to content
This forum will be closing down. Please move to the respective dedicated project forums.

Create a new sound instance from existing sound in cache


Nick
 Share

Recommended Posts

I need to create multiple sound instances so I can play overlapping sounds in IE.  I originally tried creating multiple instances of Phaser.Sound which uses the same key however this only created 1 Audio tag so only 1 sound could be played at a time.

 

So now I'm loading in the same sound file in the cache multiple times.

 

this.load.audio( 'sounds-1', app.audioDir + 'sounds.m4a' );this.load.audio( 'sounds-2', app.audioDir + 'sounds.m4a' );this.load.audio( 'sounds-3', app.audioDir + 'sounds.m4a' );this.load.audio( 'sounds-4', app.audioDir + 'sounds.m4a' );
 
However I can't trust IE to download the first file then the rest from the cache. 
 
So I was wondering if there was a way to only download the file once and then create new sounds elements that can be played of the data from the first. I've tried the following but it doesn't appear to create a new audio element which can be played:
 
this.load.audio( 'sounds-1', app.audioDir + 'sounds.m4a' );
this.cache.addSound( 'sounds-2', app.audioDir + 'sounds.m4a',  this.cache.getSoundData('sounds-1'), false, true);
 

So I guess what I need is a way to do the same thing that loading an audio file does without having to create a new HTTP request, as the file has already been downloaded. 

 

Any ideas appreciated :)

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...