Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML5 Sound plugin?

Currently I'm using soundmanager2 to power sounds in my web app. SoundManager uses Flash, which sometimes crashes, killing sounds. Is there a reliable plugin available in jQuery that powers sounds using HTML5 rather than with Flash?

My Settings:

soundManager.url = '/misc/soundmanager2/v20111220/';    // SoundManager fails if the SWF is loaded from the CDN
soundManager.debugMode = true;
soundManager.flashVersion = 9;
soundManager.useFlashBlock = false;
soundManager.useHTML5Audio = true;
like image 340
AnApprentice Avatar asked Jan 24 '12 18:01

AnApprentice


3 Answers

SoundManager can also play pure HTML5 sound.

SoundManager 2 gives you a single, powerful API that supports both new and old, using HTML5 audio where supported and optional Flash-based fallback where needed. Ideally when using SoundManager 2, audio "just works."

Flash is only (optionally) used as fallback. Or for some nifty stuff which isn't (very well) supported (yet) by all browsers. Like a spectrum analyzer etc.

To 'force' SoundManager2 to use HTML5 audio you can add the following parameter:

soundManager.preferFlash = false;

overrides useHTML5audio. if true and flash support present, will try to use flash for MP3/MP4 as needed since HTML5 audio support is still quirky in browsers.

From the official docs.

like image 153
PeeHaa Avatar answered Oct 03 '22 08:10

PeeHaa


Description

I suggest jPlayer.

jPlayer is the completely free and open source (GPL/MIT) media library written in JavaScript. A jQuery plugin, jPlayer allows you to rapidly weave cross platform audio and video into your web pages. jPlayer's comprehensive API allows you to create innovative media solutions while support and encouragement is provided by jPlayer's active and growing community.

Sample

$(document).ready(function(){
 $("#jquery_jplayer_1").jPlayer({
  ready: function () {
   $(this).jPlayer("setMedia", {
    m4a: "/media/mysound.mp4",
    oga: "/media/mysound.ogg"
   });
  },
  swfPath: "/js",
  supplied: "m4a, oga"
 });
});

More Information

  • jPlayer - The jQuery HTML5 Audio / Video Library
like image 44
dknaack Avatar answered Oct 03 '22 07:10

dknaack


Use the HTML5 Audio tag as shown in this link.

like image 30
LenPopLilly Avatar answered Oct 03 '22 08:10

LenPopLilly