Play audio onHover with jQuery
04.Oct.2012 | Posted by admin | Filed under JQuery Plugins
The simplest way to play audio files in your page without the need of flash is the usage of HTML5 tag <audio> as follow:
<audio autoplay="autoplay" controls="controls" loop="loop" preload="preload">
<source src="beep.ogg" type="audio/ogg">
<source src="beep.mp3" type="audio/mpeg">Your Browser doesn't support audio
</audio>
For our example we only need the attributes "autoplay" and the two tags "source" to define the url of the audio files. Just like this:
<audio autoplay="autoplay">
<source src="beep.ogg" type="audio/ogg">
<source src="beep.mp3" type="audio/mpeg">
</audio>
Now we let jQuery take over by embedding the html code for all <a> tags whenever onMouseOver is done:
$(document).ready(function(){
var audioFileName = "beep";
var mp3File = audioFileName + ".mp3";
var oggFile = audioFileName + ".ogg";
$('body').append('<div id="audio" style="position:absolute; top:-200px;"></div>');
$('a').hover(function(){
$('#audio').html('<audio autoplay="autoplay">'+
'<source src="' + oggFile + '" type="audio/ogg">'+
'<source src="' + mp3File + '" type="audio/mpeg"></audio>');
},
function(){ });
});
Thats it!
DEMO: Check the upper menu of this page to hear how it works
Useful Links:
0 Comments
Write a Comment
Development
Latest Posts
- Dynamic CSS via PHP
- CLEditor Plugin: MyStyles Plugin
- Creating a simple Tooltip in jQuery
- RegExp in SqLite using Php
- jSound - jQuery plugin
- jmotion - jQuery plugin
- Play audio onHover with jQuery
- Black Search plugin
- Japng Image animator
- Themes for Havalite
- mb.mediaEmbedder
- Replace2Anchor
- Plugins and Widgets for Havalite
- iFrame plugin
- Google Fonts Plugin
- Hierarchical Category
- Creating Widgets for Havalite CMS
- Tag Cloud Viewer
- jWise plugin for Havalite
- Print this page 1.0
- Banner us
- Export Manager 1.0
- Developing Themes for Havalite
- Visitor Counter
- Adding Sidebar widgets
- Video Tutorials
- JDaedalum - A Gif like animation
- Plugins and Widgets Development
- Sortable2php
- timeSpam
- TipTip
- UItoTop
- HavaToDo
- Upgrading to Havalite 1.1.1.
- code embedder
- Havalite Interface Translation
- Upgrading to Havalite 1.0.9
- Error Pages
Categories
Support Styleshout
If you are interested in supporting our work and would like to contribute, you are welcome to make a small donation through the donate button down here- it will be a great help and will surely be appreciated.
Reached: 155 € goes to charity
mp3, api jquery jquery, css hover, variables banner swf plugins, layouts sqlite html5 image widgets sqlite3 open spam html widget iframe javascript filter flash download effects install php havalite stylesheet audio, code free demo plugin update youtube htaccess design javascript, counter google templates gif text management database ckeditor images html5, css, cms blog generator themes source plugins fonts system effect ui mp3 editor content form upgrade
Counting since 08.08.2012




















