当用户点击html5中的特定链接时,如何播放音频文件 [英] How to play audio files when user clicks on that particualar link in html5

查看:372
本文介绍了当用户点击html5中的特定链接时,如何播放音频文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在用户点击特定链接时播放音频文件。我使用创建了某些链接。现在,当我点击该链接时,我希望播放音乐。

解决方案

JavaScript是语言,找到一些有用的东西,可以让你写出来HTML元素的JavaScript( audio video )。在大多数情况下,现成的插件是解决这些问题的最佳解决方案。您可以获得一个媒体播放器,将其嵌入您的网站,它会为您处理一切。您根本不需要做任何事情,其中​​大部分都是免费的,也没有版税。我还建议您使用其中一个插件并使用它们而不是浪费2-5个月来编写新插件要求更多代码



Google搜索 [ ^ ]为JavaScript插件提供了10个以上的结果(jQuery插件构建于jQuery之上;而后者则依赖于jQuery JavaScript的顶部)。您可以从其中任何一个中进行选择,并将它们嵌入到您的代码中。编写插件很容易,但在做任何有用的事情之前需要更多的理解。 : - )


请参阅:

https:// en .wikipedia.org / wiki / HTML5_Audio [ ^ ] ,

https://developer.mozilla.org/en -US / docs / Web / Guide / HTML / Using_HTML5_audio_and_video [ ^ ],

http://www.htmlgoodies.com/primers/html/article.php/3920991/HTML5-Primer-How-To-Use-the-Audio -Tag.htm [ ^ ]。



-SA

I want to play audio files when user clicks on a particular link. I made certain links using . Now when I click on that link I want that music to played.

解决方案

JavaScript is the language, find something useful that will allow you to write the JavaScript for the HTML elements (audio or video). In most cases, ready-made plugins are a great solution to those problems. You can get a media player, embed it in your website and it handles everything for you. You don't have to do anything at all, most of them are free of cost and free of royalty also. I would also recommend that you get one of those plugins and use them rather than wasting 2-5 months in writing a new plugin by asking for more code.

This Google search[^] gave like 10+ results for JavaScript plugins (jQuery plugins are built on top of jQuery; which in turn is written on top of JavaScript). You can chose from either one of them, and embed them in your code. Writing a plugin is easy, but needs much more understanding before you can do anything useful. :-)


Please see:
https://en.wikipedia.org/wiki/HTML5_Audio[^],
https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Using_HTML5_audio_and_video[^],
http://www.htmlgoodies.com/primers/html/article.php/3920991/HTML5-Primer-How-To-Use-the-Audio-Tag.htm[^].

—SA


这篇关于当用户点击html5中的特定链接时,如何播放音频文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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