如何在jQuery中获取对象标签的持续时间并在特定时间播放视频?
<div id="sound" >
<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" WIDTH="0" HEIGHT="0" id="Yourfilename" ALIGN="">
<PARAM NAME=movie VALUE="sample.swf">
<PARAM NAME=quality VALUE=high>
<PARAM NAME=bgcolor VALUE=#333399>
<EMBED src="sample.swf" quality=high bgcolor=#333399 WIDTH="0" HEIGHT="0" NAME="Yourfilename" ALIGN="" TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer">
</EMBED>
</OBJECT>
</div>
我想获取这个声音的持续时间,并将其转换为秒,然后从特定时间开始播放这个声音。
例如,从40秒开始播放这个声音。
我该怎么做呢?
<div id="sound" >
<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" WIDTH="0" HEIGHT="0" id="Yourfilename" ALIGN="">
<PARAM NAME=movie VALUE="sample.swf">
<PARAM NAME=quality VALUE=high>
<PARAM NAME=bgcolor VALUE=#333399>
<EMBED src="sample.swf" quality=high bgcolor=#333399 WIDTH="0" HEIGHT="0" NAME="Yourfilename" ALIGN="" TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer">
</EMBED>
</OBJECT>
</div>
I want to get the duration time of this sound, and convert it to seconds, then play this sound from a specific time.
For example, playing this sound from 40 seconds.
How can I do it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我正在尝试解决这个问题,但到目前为止我还不能。当我使用
它时,它返回 NAN 。
I'm trying to solve this problem but till now i can't. When I used
it returns NAN .
正如之前所告诉您的,不要使用已弃用的标签,并尝试使用 HTML5 中的新
标签来执行此操作。
您必须调用
audio.duration
。检查 this 已经回答了同一网站的问题。尝试这样的事情:祝你好运。
编辑:如果您想在 20 秒后开始,您应调用
audioElement.currentTime=20;
,然后在您的位置调用audioElement.play();
js$(document).ready(function())
.询问是否还需要其他东西。As you have been told previously, don't use deprecated tags, and try to use the fresh
<audio>
tag from HTML5 for doing that.You'll have to call
audio.duration
. Check this already answered question from this same site. Try something like this:Good luck.
Edited: If you want to start after, i.e., 20 seconds, you shall call to
audioElement.currentTime=20;
and then calling toaudioElement.play();
at your js$(document).ready(function())
. Ask if you need anything else.