[轉]在網頁中加入聲音文件,並且用JavaScript對其進行播放控制

<%@ 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>
 
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章