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
14
S
3
G
5
Posts: 41
Reputation: 3,490

Post » Wed Jan 11, 2012 11:34 pm

Thanks for this might be worth making a plugin to do this
B
29
S
12
G
7
Posts: 740
Reputation: 7,839

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
359
S
214
G
72
Posts: 22,949
Reputation: 178,544


Return to Construct 2 General

Who is online

Users browsing this forum: fredriksthlm, MilkGames, shinichild and 8 guests