8 个解决方案
#1
在JS里面写随机吧
#2
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
request.setCharacterEncoding("utf-8");
String mName = request.getParameter("mName");
%>
<html>
<head>
</head>
<body>
<h1><%=mName %></h1>
<object id="player" height="360" width="300" classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6">
<param NAME="AutoStart" VALUE="1"> <!--是否自动播放-->
<param NAME="url" value="<%="musics/"+mName %>"> <!--播放的文件地址-->
<param NAME="PlayCount" VALUE="1">
</object>
</body>
</html>
<%
request.setCharacterEncoding("utf-8");
String mName = request.getParameter("mName");
%>
<html>
<head>
</head>
<body>
<h1><%=mName %></h1>
<object id="player" height="360" width="300" classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6">
<param NAME="AutoStart" VALUE="1"> <!--是否自动播放-->
<param NAME="url" value="<%="musics/"+mName %>"> <!--播放的文件地址-->
<param NAME="PlayCount" VALUE="1">
</object>
</body>
</html>
#3
<embed id="soundControl" src="文件路径及文件" 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')" />
function ManageSoundControl(action)
{
var soundControl = document.getElementById("soundControl");
if(action == "play")
{
soundControl.play();
}
if(action == "stop")
{
soundControl.stop();
}
}
用这个试试
#4
再说一种JS隐式播放方式:
在页面body里加上
在<head></head>之间加上
声音文件尽量要小
在页面body里加上
<bgsound id="snd" loop="0" src="">
<input type="button" value="声音" onclick="playSound('这里填写你的声音文件路径')">
在<head></head>之间加上
<script>
function playSound(src){
var _s = document.getElementById('snd');
if(src!='' && typeof src!=undefined){
_s.src = src;
}
}
</script>
声音文件尽量要小
#5
<html>
<head>
<title>sound test</title>
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" >
$(function(){
$('a.click').click(function(){
$('embed').remove();
$('body').append('<embed src="notify.wav" autostart="true" hidden="true" loop="false">');
});
$('a.hover').mouseover(function(){
$('embed').remove();
$('body').append('<embed src="notify.wav" autostart="true" hidden="true" loop="false">');
});
});
</script>
</head>
<body>
<p><a href="#" class="click">点击后发声提示</a></p>
<p><a href="#" class="hover">鼠标在上面发声提示</a></p>
</body>
</html>
#6
#7
关注,留下脚印
#8
#1
在JS里面写随机吧
#2
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
request.setCharacterEncoding("utf-8");
String mName = request.getParameter("mName");
%>
<html>
<head>
</head>
<body>
<h1><%=mName %></h1>
<object id="player" height="360" width="300" classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6">
<param NAME="AutoStart" VALUE="1"> <!--是否自动播放-->
<param NAME="url" value="<%="musics/"+mName %>"> <!--播放的文件地址-->
<param NAME="PlayCount" VALUE="1">
</object>
</body>
</html>
<%
request.setCharacterEncoding("utf-8");
String mName = request.getParameter("mName");
%>
<html>
<head>
</head>
<body>
<h1><%=mName %></h1>
<object id="player" height="360" width="300" classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6">
<param NAME="AutoStart" VALUE="1"> <!--是否自动播放-->
<param NAME="url" value="<%="musics/"+mName %>"> <!--播放的文件地址-->
<param NAME="PlayCount" VALUE="1">
</object>
</body>
</html>
#3
<embed id="soundControl" src="文件路径及文件" 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')" />
function ManageSoundControl(action)
{
var soundControl = document.getElementById("soundControl");
if(action == "play")
{
soundControl.play();
}
if(action == "stop")
{
soundControl.stop();
}
}
用这个试试
#4
再说一种JS隐式播放方式:
在页面body里加上
在<head></head>之间加上
声音文件尽量要小
在页面body里加上
<bgsound id="snd" loop="0" src="">
<input type="button" value="声音" onclick="playSound('这里填写你的声音文件路径')">
在<head></head>之间加上
<script>
function playSound(src){
var _s = document.getElementById('snd');
if(src!='' && typeof src!=undefined){
_s.src = src;
}
}
</script>
声音文件尽量要小
#5
<html>
<head>
<title>sound test</title>
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" >
$(function(){
$('a.click').click(function(){
$('embed').remove();
$('body').append('<embed src="notify.wav" autostart="true" hidden="true" loop="false">');
});
$('a.hover').mouseover(function(){
$('embed').remove();
$('body').append('<embed src="notify.wav" autostart="true" hidden="true" loop="false">');
});
});
</script>
</head>
<body>
<p><a href="#" class="click">点击后发声提示</a></p>
<p><a href="#" class="hover">鼠标在上面发声提示</a></p>
</body>
</html>
#6
#7
关注,留下脚印