如何将音乐文件(如mp3,rm)嵌入到网页中
1><body>
<embed id="MediaPlaye" name="MediaPlaye" src='31.mp3' autostart=1 loop=1></embed>
<input type=button onclick="document.embeds('MediaPlaye').stop()" value=stop>
<input type=button onclick="document.embeds('MediaPlaye').play()" value=play>
</body>
2><html>
<body>
<p>
<object classid="clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95" id="MediaPlayer1" width="281" height="238">
<param name="AudioStream" value="-1">
<param name="AutoSize" value="0">
<param name="AutoStart" value="-1">
<param name="AnimationAtStart" value="-1">
<param name="AllowScan" value="-1">
<param name="AllowChangeDisplaySize" value="-1">
<param name="AutoRewind" value="0">
<param name="Balance" value="0">
<param name="BaseURL" value>
<param name="BufferingTime" value="5">
<param name="CaptioningID" value>
<param name="ClickToPlay" value="-1">
<param name="CursorType" value="0">
<param name="CurrentPosition" value="-1">
<param name="CurrentMarker" value="0">
<param name="DefaultFrame" value>
<param name="DisplayBackColor" value="0">
<param name="DisplayForeColor" value="16777215">
<param name="DisplayMode" value="0">
<param name="DisplaySize" value="4">
<param name="Enabled" value="-1">
<param name="EnableContextMenu" value="-1">
<param name="EnablePositionControls" value="-1">
<param name="EnableFullScreenControls" value="0">
<param name="EnableTracker" value="-1">
<param name="Filename" value>
<param name="InvokeURLs" value="-1">
<param name="Language" value="-1">
<param name="Mute" value="0">
<param name="PlayCount" value="1">
<param name="PreviewMode" value="0">
<param name="Rate" value="1">
<param name="SAMILang" value>
<param name="SAMIStyle" value>
<param name="SAMIFileName" value>
<param name="SelectionStart" value="-1">
<param name="SelectionEnd" value="-1">
<param name="SendOpenStateChangeEvents" value="-1">
<param name="SendWarningEvents" value="-1">
<param name="SendErrorEvents" value="-1">
<param name="SendKeyboardEvents" value="0">
<param name="SendMouseClickEvents" value="0">
<param name="SendMouseMoveEvents" value="0">
<param name="SendPlayStateChangeEvents" value="-1">
<param name="ShowCaptioning" value="0">
<param name="ShowControls" value="-1">
<param name="ShowAudioControls" value="-1">
<param name="ShowDisplay" value="0">
<param name="ShowGotoBar" value="0">
<param name="ShowPositionControls" value="-1">
<param name="ShowStatusBar" value="0">
<param name="ShowTracker" value="-1">
<param name="TransparentAtStart" value="0">
<param name="VideoBorderWidth" value="0">
<param name="VideoBorderColor" value="0">
<param name="VideoBorder3D" value="0">
<param name="Volume" value="0">
<param name="WindowlessVideo" value="0">
</object>
</p>
</body>
</html>
<HTML>
<HEAD>
</HEAD>
<BODY>
<OBJECT ID="Player" height="0" width="0"
CLASSID="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6">
</OBJECT>
<INPUT TYPE="BUTTON" NAME="BtnPlay" VALUE="Play" OnClick="StartMeUp()">
<INPUT TYPE="BUTTON" NAME="BtnStop" VALUE="Stop" OnClick="ShutMeDown()">
<SCRIPT>
<!--
function StartMeUp ()
{
Player.URL = "laure.wma";
}
function ShutMeDown ()
{
Player.controls.stop();
}
-->
</SCRIPT>
</BODY>
</HTML>
5>rm文件制作出来了,在本地用REALPLAY可以播放,但放到服务器还是报告“出现常规错误。”
我嵌入播放器的代码是这么写的:
<object width="500" height="450" classid="clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA">
<param name="CONTROLS" value="ImageWindow">
<param name="CONSOLE" value="Video">
<param name="CENTER" value="TRUE">
<param name="MAINTAINSPECT" value="TRUE">
<param name="SRC" value="../medias/<%=Request("id")%>.rm">
</object>
其中Request("id")是rm文件名。是不是不能这样直接播放RM文件?或者还要架设什么流媒体服务器?
<span id="mp3"></span>
<script language="JavaScript">
var mPlayCode = "<OBJECT id=MediaPlayer width=360 height=42 codeBase=http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,1,5,217 type=application/x-oleobject classid=clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95></OBJECT>";
function PlayOf(Obj){
if (document.all["mp3"].innerHTML != mPlayCode){document.all["mp3"].innerHTML = mPlayCode;}
MediaPlayer.stop();
MediaPlayer.EnableContextMenu = 0;
MediaPlayer.PlayCount = 99;
MediaPlayer.Volume = -1;
MediaPlayer.AutoStart = 1;
MediaPlayer.Filename = Obj;
}
</script>
<a href="arli://" onclick="PlayOf('/MPGFILE/MYFILE.MPG');return false;">click Play</a>
<object classid="clsid:CFCDAA03-8BE4-11CF-B84B-0020AFBBCCFA" id="RealAudio1" width="300" height="227">
<param name="_ExtentX" value="7938">
<param name="_ExtentY" value="6006">
<param name="AUTOSTART" value="-1">
<param name="SHUFFLE" value="-1">
<param name="PREFETCH" value="0">
<param name="NOLABELS" value="0">
<param name="SRC" value="/rm/大话西游之月光宝盒A.rmvb">
<param name="CONTROLS" value="ImageWindow,controlpanel">
<param name="LOOP" value="0">
<param name="NUMLOOP" value="0">
<param name="CENTER" value="-1">
<param name="MAINTAINASPECT" value="0">
<param name="BACKGROUNDCOLOR" value="#000000">
</object>
在我这是正常的,如果你出现常规错误(一般是文件没找到或不正常的传输格式)就可能是服务器对rm 和mpg 之类的进行了mime 映射,使它不以流的方式传输,目前有很多的空间是这样以避免流量超载。
摘自CSDN.