How to play sound in a Chrome application?

1

I have an application for Google Chrome and I want it to issue a sound every time a notification is created, but in my tests I did not have much success = p

I do not know if it's some permission or if there really is not any way I can do it.

Do you know any way? (Detail: I wanted the js file in the background to do this)

    
asked by anonymous 18.02.2014 / 01:46

1 answer

1

Have you tried using the Web Audio API?

 var context = new webkitAudioContext();
 var oscillator = context.createOscillator();
 oscillator.connect(context.destination);
 oscillator.frequency.value = 780; //frequencia do som, altere pra mudar o som que será emitido
 oscillator.start(0);
 oscillator.stop(context.currentTime + 0.5)//duração do som;

If you use the light API in mind that the oscillator is destroyed after use, for each sound you must create a new one.

Cross-browser: link

Example taken from: link

    
18.02.2014 / 20:16