[转]在网页中加入声音文件,并且用JavaScript对其进行播放控制
16lz
2021-01-22
<%
@PageLanguage
=
"
C#
"
AutoEventWireup
=
"
true
"
CodeFile
=
"
Default.aspx.cs
"
Inherits
=
"
_Default
"
validateRequest
=
"
false
"
%>
<! DOCTYPEhtmlPUBLIC " -//W3C//DTDXHTML1.0Transitional//EN " " http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd " >
< htmlxmlns = " http://www.w3.org/1999/xhtml " >
< headrunat = " server " >
< title > 无标题页 </ title >
< scriptlanguage = " javascript " type = " text/javascript " >
// 用javascript进行声音播放控制
functionManageSoundControl(action)
{
varsoundControl=document.getElementById("soundControl");
if(action=="play")
{
soundControl.play();
}
if(action=="stop")
{
soundControl.stop();
}
}
</ script >
</ head >
< body >
< formid = " form1 " runat = " server " >
< tablewidth = " 100% " >
< tr >
< td >
< embedid = " soundControl " src = " 求佛.mp3 " mastersoundhidden = " true " loop = " false " autostart = " false " ></ embed >
< inputid = " btPlay " type = " button " value = " 播放 " onclick = " ManageSoundControl('play') " />
< inputid = " btStop " type = " button " value = " 播放 " onclick = " ManageSoundControl('stop') " />
</ td >
</ tr >
</ table >
</ form >
</ body >
</ html >
<! DOCTYPEhtmlPUBLIC " -//W3C//DTDXHTML1.0Transitional//EN " " http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd " >
< htmlxmlns = " http://www.w3.org/1999/xhtml " >
< headrunat = " server " >
< title > 无标题页 </ title >
< scriptlanguage = " javascript " type = " text/javascript " >
// 用javascript进行声音播放控制
functionManageSoundControl(action)
{
varsoundControl=document.getElementById("soundControl");
if(action=="play")
{
soundControl.play();
}
if(action=="stop")
{
soundControl.stop();
}
}
</ script >
</ head >
< body >
< formid = " form1 " runat = " server " >
< tablewidth = " 100% " >
< tr >
< td >
< embedid = " soundControl " src = " 求佛.mp3 " mastersoundhidden = " true " loop = " false " autostart = " false " ></ embed >
< inputid = " btPlay " type = " button " value = " 播放 " onclick = " ManageSoundControl('play') " />
< inputid = " btStop " type = " button " value = " 播放 " onclick = " ManageSoundControl('stop') " />
</ td >
</ tr >
</ table >
</ form >
</ body >
</ html >