Simple JavaScript Audio Player with SoundManager2


/ Published in: JavaScript
Save to your folder(s)

Simple [SoundManager2](http://www.schillmania.com/projects/soundmanager2/doc/download/#latest "Download SoundManager2") example (uses jQuery)


Copy this code and paste it in your HTML
  1. <!--# Add to <head> #-->
  2.  
  3. <script type="text/javascript" src="/path/to/soundmanager2-nodebug-jsmin.js"></script>
  4. <script type="text/javascript">
  5. //<![CDATA[
  6.  
  7. $(document).ready(function () {
  8. soundManager.url = '/path/to/sm2-flash-movies/'; // directory where SM2 .SWFs live
  9. soundManager.onload = function() {
  10. // SM2 is ready to go!
  11. var mySound = soundManager.createSound({
  12. id: 'aSound',
  13. url: '/path/to/an.mp3',
  14. autoLoad: true,
  15. autoPlay: false
  16. });
  17.  
  18. // Play/Pause Toggle Button
  19. $('#toggleBtn').click(function () {
  20. soundManager.togglePause('aSound');
  21. });
  22. }
  23. });
  24.  
  25. //]]>
  26. </script>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.