[英]jQuery, Html5 audio player submit form after finished
Is there a way to detect html5 audio player when finished? 完成后是否有办法检测html5音频播放器?
I'd like to submit a form after the audio is finished. 音频播放完毕后,我想提交一份表格。
<audio controls>
<source src="horse.ogg" type="audio/ogg">
Your browser does not support the audio tag.
</audio>
$( document ).ready(function() {
// when audio finished
$(".form_sub #submit").trigger('click');
});
<form class="form_sub">
<input type="submit" value="Submit" name="submit" id="submit">
</form>
The <audio>
element has an ended
event that you can listen for. <audio>
元素具有一个ended
事件,您可以收听。 https://developer.mozilla.org/en-US/docs/Web/Guide/Events/Media_events https://developer.mozilla.org/zh-CN/docs/Web/Guide/Events/Media_events
You might need to do some testing to weed out some quirks and to determine browser support. 您可能需要进行一些测试,以消除一些怪癖并确定浏览器支持。
There are a whole bunch of events associated with the audio player. 与音频播放器相关的事件很多。 This may be what you are looking for. 这可能是您要寻找的。
var aud = document.getElementById("myAudio");
aud.onended = function() {
alert("The audio has ended");
};
More can be found here: http://www.w3schools.com/tags/av_event_ended.asp 可以在这里找到更多信息: http : //www.w3schools.com/tags/av_event_ended.asp
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.