Wednesday, February 13, 2013

Add music to your website by HTML5

Ago to add music to your blog you will have to use a 3rd party plugin support HTML5 flash but when the birth was help for webmasters and content management a much lighter burden. However right now it has become much simpler that you can add music directly on your website with just one card<audio>

HTML5's <audio> card now supports the latest browsers are listed here

However, as a webmaster you need to anticipate some cases may occur as your browser does not support HTML5 (her mentioning this extremely annoyed with these guys IE - stupid beyond description - sr you) . So this article I will guide negate the state plan does not support HTML5 in some older browsers.

1. Simple syntax

Its syntax is very simple, you just insert card <audio> with few parameters is done. The most basic you just need to insert:

<audio src=audio.mp3" controls />

Attribute display controls help a slider control on the browser. It should be noted that this slider will be different on different browsers. As follows

2. Advanced properties

However, in order to completely control cards <audio> , I have to learn a number of important attributes.

scr

It specifies the audio file is played. This property may be familiar with him I would meet the most is when inserting images into posts such <img> tag has this attribute.

controls

As in the example above, this attribute that shows a slider control.

autoplay

This attribute will be automatically tracks a bit as soon as the page loads. Attention offline, brothers very hydrophobic case. There are many sites do not bother to read because disturb others with the background music. If used, they must be sure how readers can turn off the sound quickly.

loop

Loop. When playing music, browsers will automatically play back the track from the beginning all over again. It is an infinity loop infinity loop.

preload {auto | metadata | none}

Preload attribute specifies whether or not to download music files. It only FF, Chrome and Safari support.

3. Support for older browsers

HTML5 is the new and only some versions of the new browser support it, for the browser version older people still have to rely on third-party plugins flash-based activities such as jw player. So how to both use HTML5 to use flash? HTML5 has anticipated this and its solution incredibly simple.

First, we can notice a line of text to the reader to know that their browser does not support HTML5 should not hear the music.

Card <audio> of HTML5 also allows us to insert into the middle of it an object and so we relaxed by adding the plugin to the music. In case the plugin does not work, there is still text between <p>card

4. Limit Break!

But today's mobile world as more and more products like the iPhone, iPad, smartphone. Tablet web browsing capabilities make stars to the browsers on these devices can also play music?

The code decoders of different browsers led to the kind of file that the browser understands the other browsers do not understand the "tissue" anything. If you want all the browsers on mobile devices are out, you must use the following code.

This code works as follows: The browser supports HTML5 will read card <audio> it that to play a music file, but the files? It will start and will play the first file that it understands the file if it does not understand at all, it starts read came <object> and music based on the plugin. If you do not understand any more, it had a line of text between <p> card

With HTML5 now to add music to website easy backstroke, is like inserting an image. HTML5 has revolutionized our help webmasters more "breathable" and great user experience. No doubt HTML5 is the standard of modern web design.