13 Replies Latest reply on Mar 24, 2012 12:47 PM by garciacity

    Edge + sound + HTML5

    Nik Ska

      For all who wondered how to include sounds in your animation project without coding too much.

       

      So here's the script, SoundManager2

      http://www.schillmania.com/projects/soundmanager2/

       

      And here's what you do:

      1. You edit .html file, and add the following lines AFTER <!--Adobe Edge Runtime End-->

       

        <script type="text/javascript" charset="utf-8" src="soundmanager2-nodebug-jsmin.js"></script>

       

                <script type="text/javascript">

       

                soundManager.url = 'swf/'; // path to .swf files

                soundManager.useHTML5Audio = true; //html audio support

                soundManager.onready(function(){

          var mySound = soundManager.createSound({

          id: 'aSound',

          url: 'sounds/glass_shatter_01.mp3' //path to the sound

                  });

                  mySound.play(); //this will play your sound on open

                });

                </script>

       

      2. Now you are free to play the sound whenever you like by doing the following:

       

      var sound = soundManager.getSoundById('aSound');

      sound.play();

       

      3. Voila.

       

      Of course it's a simple way, but soundmanager documentation is pretty complete, so you won't have any trouble working with it.

       

      here's a link to the test project: http://drugdealers.ru/test/sound/soundtest.html

      and a zipped project: http://drugdealers.ru/test/sound.zip