visitor (0 QPoints)
  • FR
  • EN
  • NL
  • DE
  • ES
315 experts, 1193 registered users, 1659 questions already answered
European Experts Exchange, the very best site for high-quality IT solutions

New Improved Search!

 


05/10/2011 1h30 : Steve Jobs is dead, the father of Apple ][ is gone, we are all orphaned.

Languages :: DHTML, JScript :: how to have sound in a web page in a standard way ? W3C solution ? embed ? object ? bgsound ?


By: PHP newbee U.S.A.  Date: 26/05/2006 11:12:06  English  Points: 20 Status: Answered
Quality : Excellent
I would hate to use an ActiveX for only having a short sound file (WAV format) to play in the client's browser... And I would like it to work even for modern browsers, so using EMBED is not a solution. BGSOUND neither.
I don't want fancy MIDI controls ; I don't want QuickTime plugin popping up with its blue Q and silly controls. I just want the sound to be played once and that's all.

Can this be done ?
By: VGR Date: 26/05/2006 11:18:55 English  Type : Answer
Well, as you probably know, sound support (and generally speaking, media files support) is ***very*** browser-dependent. The user may even have deactivated inline sound in its browser's preferences, or could have disabled all sound altogether.

You can ***try*** to make a standards-compliant code with something like this, which at least works in IE6 and FF/FX :

The function hereafter returns the HTML string, so either store it and echo it afterwards, or echo GetSound($filename); directly

function GetSound($datafile) { //VGR26052004 MOD sound handling to conform to W3C recommendations (keep EMBED or BGSOUND for IE) //VGR REM WMP = classid="CLSID:05589FA1-C356-11CE-BF01-00AA0055595A" //VGR REM FlashP = classid="CLSID:D27CDB6E-AE6D-11cf-96B8-444553540000" //VGR REM type="audio/wav" also possible //VGR REM generating browser-specific code is also feasible. $thesound="<embed src=\"$datafile\" hidden=true autostart=true loop=false volume=75 mastersound><noembed><object type=\"audio/x-wav\" data=\"$datafile\" width=1 height=1><bgsound src=\"$datafile\" loop=false></object></noembed></embed>"; return($thesound); } // GetSound String Function


Do register to be able to answer

EContact
browser fav
page generated in 510.010000 milliseconds

Why Google AdSense ads ?

compteur
 Ranking-Hits PageRank for this page