如何检测一个音频已经完成在网页中的玩? [英] How to detect an audio has finished playing in a web page?

查看:137
本文介绍了如何检测一个音频已经完成在网页中的玩?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的项目,我需要嵌入音频(例如:MP3等)转换成网页。当用户访问该页面时,音频将开始播放。当音频结束时,问卷(表单域)将出现为用户应答

In my project, I need to embed audio (ex: mp3, etc) into a web page. When user visits the page, the audio will begin playing. When the audio ends, the questionnaire (form fields) will appear for the user to answer.

时有方式,以检查是否该音频已完成使用jquery播放,所以该问卷可以出现在用户收听整个音频后

Is there is way to check if the audio has finished playing using jquery, so that the questionnaire can appear after the user has listened to the entire audio?

我知道检查的一种方法是确定音频的长度,那么我可以设置一个计时器,以显示调查问卷,但我希望jQuery有某种事件处理程序,可以让我做到这一点。

I know one way to check is to determine the audio length, then I can set a timer to display the questionnaire, but I'm hoping jquery has some sort of event handler that allows me to accomplish this.

我看到jQuery有许多音频插件,我不能肯定这将做什么,我想在这里:<一href=\"http://plugins.jquery.com/plugin-tags/audio\">http://plugins.jquery.com/plugin-tags/audio

I see that jquery has many audio plugins, and I can't be sure which will do what I want here: http://plugins.jquery.com/plugin-tags/audio

任何想法是极大的AP preciated。

Any ideas are greatly appreciated.

感谢。

推荐答案

如果您使用的是HTML5音频标记,有onended事件处理程序。我不知道,如果浏览器都支持它。

If you are using the html5 audio tag, there is the "onended" event handler. I don´t know if the browsers support it yet.

是这样的:

<audio src="xpto.mp3" onended="DoSomething();"></audio>

在过去的情况下,你可以使用SWF可以播放声音,并提醒你的JavaScript,当它到达终点。

In the last case you can use a swf that can play the sound, and alert your javascript when it reaches the end.

这篇关于如何检测一个音频已经完成在网页中的玩?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆