GOTO

Thursday, May 6, 2010

An alternative to audio tag

Hi everybody,

last week I had a problem with the new tag audio included in html5: I wasn't able to reproduce mp3 files in Firefox browser. I've reported this in bugzilla and Mozilla's staff replied that Mozilla haven't the right licence...
I've discover another tag named "embed". I would report an alternative method for playing mp3 using this new tag and dynamic html:

HTML code

<span id=player></span>
<form>
<input type="button" value="Play my song" onClick="Play('Panama.mp3')">
</form>

Javascript code

function Play(url) {
document.getElementById("player").innerHTML=
"<embed src='"+url+"' hidden=true autostart=true height=0 width=0
loop=false>";
}

Setting height and width parameters to 0 to hide the player. How I said some posts ago, mp3 files are simply to concatenate like wav, but have small sizes. This method is also comaptible with Chrome, Opera, Explorer and, I think, Safari ( I can't try on it :) ).

::See you next post::

No comments:

Post a Comment