您的位置:首页 > Web前端 > JavaScript

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

2007-06-01 11:04 405 查看

<%@ 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>
 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息