CodeIgniter Forums
playing a little sound in the background - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: playing a little sound in the background (/showthread.php?tid=21865)



playing a little sound in the background - El Forum - 08-23-2009

[eluser]Bramme[/eluser]
Hello everybody

Has anyone ever used Facebooks chat function? When you get a new message, you hear a little beep, warning you someone has said something.

Does anyone know how to recreate something like this? I'm making a website that would need a similar type of functionality: through Ajax I need to check every 5 seconds or so if something has been updated, if it has been, a warning needs to be displayed and a sound played.

Anyone got a clue?


playing a little sound in the background - El Forum - 08-23-2009

[eluser]pistolPete[/eluser]
Have a look at these links:
http://stackoverflow.com/questions/187098/cross-platform-cross-browser-way-to-play-sound-from-javascript
http://www.schillmania.com/projects/soundmanager2/


playing a little sound in the background - El Forum - 02-19-2010

[eluser]Bramme[/eluser]
So I'm playing with soundmanager2, but for the life of me, I cannot get it to work.

Anyone got any experience with it?

This is my code:
Code:
soundManager.url = 'assets/soundmanager2/';
soundManager.debugMode = true;
soundManager.onready(function() {});
$('#tester').live('click', function() {
   soundManager.createSound({
      id: 'aSound',
      url: 'assets/pop.mp3'
   });
   soundManager.play('aSound');
});
I get the following in Firebug:
Code:
SMSound.play(): Attempting to load "aSound"
soundmanager2.js (regel 904)
soundManager.load(): assets/pop.mp3
soundmanager2.js (regel 904)
(Flash): auto-play allowed
(Flash): _start: aSound, loops: 1, nMsecOffset: 0
SMSound._onload(): "aSound" loaded.
So I know the url's are correct, the files are found, but the sound will not play. Can ayone point out what I'm doing wrong?