Food for thought: Sound Looping

Discussion and feedback on Construct 2

Post » Wed Jan 11, 2012 12:04 am

A hack for looping sound in JS has been posted here
stackoverflow

works well for firefox and other browsers:

[CODE]
myAudio = new Audio('someSound.ogg');
if (typeof myAudio.loop == 'boolean')
{
        myAudio.loop = true;
}
else
{
        myAudio.addEventListener('ended', function() {
               this.currentTime = 0;
               this.play();
        }, false);
}
myAudio.play();
[/CODE]
B
15
S
4
G
5
Posts: 42
Reputation: 3,617

Post » Wed Jan 11, 2012 11:34 pm

Thanks for this might be worth making a plugin to do this
B
30
S
13
G
7
Posts: 740
Reputation: 8,044

Post » Thu Jan 12, 2012 11:27 am

We were hoping Firefox would just add support for looping (how hard can it be?) but if they don't do it soon we'll add in the hack.
Scirra Founder
B
395
S
232
G
88
Posts: 24,368
Reputation: 193,746


Return to Construct 2 General

Who is online

Users browsing this forum: jobel and 5 guests