Languages :: DHTML, JScript :: how to have sound in a web page in a standard way ? W3C solution ? embed ? object ? bgsound ? |
|||
| By: PHP newbee |
Date: 26/05/2006 11:12:06 |
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 | 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 |
|||
©2010 These pages are served without commercial sponsorship. (No popup ads, etc...). Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE.
Please DO link to this page!








