在 Javascript/jQuery 中完全播放 wav 文件后如何更改播放链接的 css
我需要在媒体文件完全播放后更改播放链接 css/image。假设我们在页面加载时有一个“播放”图标,当用户单击“播放”图标时,它将更改为“停止”图标。现在的要求是,当媒体文件播放完毕时,停止图标必须自动更改为播放图标。下面是我们正在使用的示例 HTML 代码
CSS 代码
<style>
.css-play{
height:21px; display:block;cursor:pointer;
background: url(/images/backgrounds/ct_initial.gif) left top no-repeat;
}
.css-stop {
height:21px; display:block;cursor:pointer;
background: url(/images/backgrounds/ct_playing.gif) left top no-repeat;
}
</style>
Javascript 代码
<script type="text/javascript">
function Play(songname,ctrl)
{
document.getElementById("divEmbed").innerHTML='<embed id="sound" NAME="sound" src="'+songname+'" autostart="true" type="audio/wav" ></embed>';
ctrl.className = 'css-stop';
}
</script>
HTML 代码
<div id="divEmbed" > </div>
<a onclick="Play('preview.wav',this);" class="css-play" >click</a>
寻求任何类型的支持
I have a requirement to change the Play link css/image once the media file is played completely. Suppose that we have a Play icon when the page is loaded and when user clicks on the Play icon, it will change to Stop icon. Now the requirement is when ever the media file is played completely, stop icon must be changed Play icon automatically. Below is the sample HTML code we are using
CSS Code
<style>
.css-play{
height:21px; display:block;cursor:pointer;
background: url(/images/backgrounds/ct_initial.gif) left top no-repeat;
}
.css-stop {
height:21px; display:block;cursor:pointer;
background: url(/images/backgrounds/ct_playing.gif) left top no-repeat;
}
</style>
Javascript Code
<script type="text/javascript">
function Play(songname,ctrl)
{
document.getElementById("divEmbed").innerHTML='<embed id="sound" NAME="sound" src="'+songname+'" autostart="true" type="audio/wav" ></embed>';
ctrl.className = 'css-stop';
}
</script>
HTML Code
<div id="divEmbed" > </div>
<a onclick="Play('preview.wav',this);" class="css-play" >click</a>
Looking for any sort of support
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
由于您没有使用播放器,所以这是不可能的。
标签不像 HTML5 的
标签那样公开任何事件。您要么必须使用纯声音 flashmovie,它在最后通过从动作脚本调用它来运行您的动作。或者使用一个播放器来公开这些事件。
Since you are not using a player, that is not possible. The
<embed>
tag exposes no events like HTML5's<audio>
tag does. You would either have to use a sound-only flashmovie, that runs your action at the end by invoking it from actionscript. Or use a player, that exposes those events.