Hey guys, how u doing?
So I'm playing with DART and I want to make a sound to be played and
then rewinded to the beggining so when it's played again it starts
from the beggining. Here's some code as example. Update is called
every frame and when 'enter' is pressed explode() is called. What
happens is that the sound plays the first time but never plays again
when explode() is called and when I print explosionSound.currentTime
it is not set to 0, but to 9223372013568. Even if I try to set it to
any other number in any other time I can't do it.
AudioElement explosionSound;
PlayerShip(): super(getShipAnimSpec())
{
explosionSound = new AudioElement('sfx/explosion.ogg');
}
void update()
{
if(explosionSound.ended)
{
explosionSound.currentTime = 0;
}
}
void explode()
{
explosionSound.play();
}
That XMLHttpRequest.response error happens only if I don't compile the code to javascript and try to run the dart code. If I compile it to javascript it works. Since everything till now worked just fine using the dart code I didn't bother compiling my sources and running the .js instead of the .dart and I don't know how stupid I was for doing it...anyways.
Now the only problem left (for now) is that:* running the javascript on chrome i get this for wav, mp3 and ogg files:XMLHttpRequest cannot load file:///C:/Users/Marcel/Documents/Projects/Dart/DartType/dart-type/sfx/explosion.wav. Cross origin requests are only supported for HTTP.DartTypeLib.dart.js:4979Uncaught Error: NETWORK_ERR: XMLHttpRequest Exception 101
*running the javascript on chromium: the ogg file triggers the onSoundDecodeSuccess callback while wav and mp3 trigger onSoundDecodeFail trigger (se code bellow together with the one in a past e-mail). I'm not sure if the only ogg file is being loaded and there for is the only one successfully decoded or if all three are being successfully loaded but only ogg is successfully decoded. Any thoughts?