现在的位置: 首页 > 综合 > 正文

[转]在网页中加入声音文件,并且用JavaScript对其进行播放控制

2013年10月20日 ⁄ 综合 ⁄ 共 1291字 ⁄ 字号 评论关闭
<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" validateRequest="false"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    
<title>无标题页</title>
    
<script language="javascript" type="text/javascript">
        
//用javascript进行声音播放控制
        function ManageSoundControl(action)
        
{
            var soundControl 
= document.getElementById("soundControl");
            
if(action == "play")
            
{
                soundControl.play();
            }

            
if(action == "stop")
            
{
                soundControl.stop();
            }

        }

    
</script>
</head>
<body>
    
<form id="form1" runat="server">
        
<table width="100%">
            
<tr>
                
<td>
                     
<embed id="soundControl" src="求佛.mp3" mastersound hidden="true" loop="false" autostart="false"></embed>
                     
<input id="btPlay" type="button" value="播放" onclick="ManageSoundControl('play')" />
                     
<input id="btStop" type="button" value="播放" onclick="ManageSoundControl('stop')" />
                
</td>
            
</tr>          
        
</table>
    
</form>
</body>
</html>

 

抱歉!评论已关闭.