Why do you need music on the site?
A rather interesting question, play music or voice files on the site, or the built-in player helps site visitors to relax, causes positive emotions and sets up to the desired way, so to speak facilitates interaction with the site. But these effects work only when the music on the site is chosen correctly and the sound volume does not exceed the permissible limits, otherwise all your efforts will be in vain and will cause negative emotions from site visitors.
How to insert audio (music) to the site in HTML?
We often ask such a question, music on the site is a relevant and creative element, and there are many ways to reproduce it and they are not so difficult to implement. Let's start with the fact that each user of the global network uses any browser to access the Internet, and there is no general and universal technology to play sound and music files, each browser works in its own algorithms and they are somewhat different from each other, so when playing music from The help of the introduction in HTML page code may arise. But as you know, all problems are solved!
Insert music to HTML, JavaScript, jQuery, Ajax methods:
1 way.Creating a music player audio on the website or player
The technology is simple, the player file is created so that it does not load the site or server choose the technology that we will use: JavaScript, jQuery, Ajax. Based on the selected technology, we develop a script for our site and insert to the site. The script is created depending on what you need: automatic reproduction of background music on the site or user-driven player. Next, create a folder at the root of the site for music and load audio files into it.
Or as an alternative compatisfaction, you can create a player on flash technology (Flash), such a player will look more effectively. The truth will be more expensive and harder for the site (will increase the time for downloading the pages of the site).
2 way.
Installing music to the site using HTML
Using HTML and browser capabilities can be inserted to the site player or background music. The technology is as simple: HTML5 code is created with the "Audio" tag and this code is written to the site, and when the user enters the site, it sees a minimized player, the visitor clicks the Play button or automatically begins to play background music. The view of the player will depend on the browser from which the visitor came, but the functionality will remain standard: the PLAY, STOP, NEXT, PREV, VOLUME buttons. Looks like a player with HTML code like this:
Cam code to insert looks like this:
As you could notice the "Controls AutoPlay" command includes music playback as soon as the visitor comes to the site.
An alternative version of HTML code is the "BGSOUND" tag, it does not use a visual player at all, when visiting the site starts playing music on the site, but adjust the volume, put on a pause, etc. The user will not be able. Setting the sound file playback is configured in the code itself.
The formats of sound files for playing music on the site can be: WAV, AU, MIDI, MP3, OGG (extensions). Music files are loaded to the site, or links to those sites where the sound file is located, the main thing is that it is in the open access.
How often did you have to look for the music you like online? That is the one you heard on your favorite site (social networks, music portals). It often happens that it is simply not else.Mate "seekers" will say that it is not. But let's consider the average user whose knowledge of technologies does not allow the "digging" in the source code of the page or cache.
It so happened that most of my friends are just such users. Here for them and it was decided to write this expansion of chromium (and the like).
What can
- Download any audio file from any site (MP3, WAV)
- Correctly determines the original name
- Shows duration, size and bit rate
- Download on the same page as a track (without redirect)
- Preview File
Some pictures and video:
I will be happy with a healthy criticism. I hope someone will be useful to this expansion.
If interested, then in the near future I will publish an overview in the source in another hub and lay out on GitHub.
Also in the plans to port in Firefox and IE.
P.S\u003e The possibility of downloading video is also there, but at the moment it is turned off (there are small problems with streaming video).
HTML language
Inserting sound and video
Sound insert. Tag
Adds, reproduces and controls the audio recordings on a web page. The path to the file is set via the attribute sRC or nested tag .
Syntax:
Some
Tag Attributes
autoPlay - the sound starts to play immediately after loading the page;
controls. - adds control panel to audio file;
loop. - repeats sound reproduction from the beginning after its completion;
preload. - Used to download the file along with the download of the web page;
sRC
The closing tag is curative.
Inside container
Example:
Insert video. Tag
Adds, reproduces and controls the video settings on a web page. The path to the file is set via the attribute sRC or nested tag .
Syntax:
Some Elements can be associated with various files. The browser will use the first launched format.
Tag Attributes
autoPlay - video starts playing automatically after page loading;
controls. - adds the control panel to the video;
loop. - repeats video playback from the beginning after its completion;
height - Specifies the height of the area to play the video;
width. - Specifies the width of the area to play the video;
preload. - Used to download video along with the download of the web page;
sRC - Specifies the path to the playable file.
The closing tag is curative.
Inside container
Example:
The result of the example in the browser:
Music on the site is rather rare than the norm. By inserting music to the site, you need to understand that some users it can and push off at all. In this article, we will look at several options inserting music to the site, as well as consider how to make background music.
How to insert background music to the site
Inserting background music on the site is the most dangerous option in terms of losing visitors. Because the background music is not enough that it is impossible to turn off, so it is also not adjustable to the volume (it all depends on the current volume on the computer). So you need to think a hundred times before inserting background music.
There are two ways to insert music in HTML
Option 1. via HTML tag
Syntax for inserting background music
Taga
There are several attributes:
- loop \u003d "value" - the number of music repetitions (if -1, then repeated infinitely)
- balance \u003d "value" - stereo balance (from -5000 to 10,000)
- volume \u003d "Value" - Volume (0 maximum, -10000 minimum)
Music will play automatically when downloading the page.
for example
Option 2. Through the tag
Syntax for inserting an object with music