How do I insert an audio track on a website?

Started by morisss, Aug 25, 2022, 04:29 PM

Previous topic - Next topic

morisssTopic starter

I want to insert my song from itunes on my website. I saw somewhere that there is a script that plays only 30 seconds of a song, and then offers to go to the appstore and purchase the full version. Can you tell me how it works?
  •  

arthyk

I suggest you take any free player - on JavaScript. Then just add a timer and a redirect to the appstore when you click the play button (click event). It will be something like this function: timer = setInterval(function () {})....
Unfortunately, there is no other ready-made solution for free. :(
  •  

Novel Web Solution

How to set background music in html:
Using the capabilities of HTML and the browser, you can also insert background music on the page.
You will need an audio file of the desired format: WAV, AU, MIDI or MP3. You can use any file with the specified extension as an example.

The first method is the embed tag. The embed element is used to load and display objects (for example, video files, flash clips, some audio files, etc.) that the browser initially does not understand.

The syntax is pretty simple:
<embed src="....mp3"></embed>
A closing tag is not required.

Now we are looking at an example of a record with attributes, and below with their decryption:

<embed src="music.mp3" width="70" height="45" align="left" hidden="False" autostart="False" loop="True">
Embed tag attributes for playing audio in html
width — panel width in pixels (or percentages)
height — the height of the panel in pixels (or percentages)
align — the location of the panel relative to the text, possible values left, right, center
hidden — allows you to hide the panel, attribute values: true — the panel is hidden, false — the panel is visible (default value)
autostart — true — the player starts automatically when the page loads, false — waits for the playback button to be pressed
loop — loop, true - the track is played in a circle, and if false — only once

    If the value is a number, Mozilla Firefox will play the melody the specified number of times, for the Explorer, the numeric value is equal to the value true.



The second way. Very old, but also practical) Add the melody to the same folder (directory) where your file is located, and write the following code in the body:

<bgsound src="Yourtrack.mp3" loop="1"></bgsound>
As a result, after loading the page, the melody you specified in the bgsound tag will sound. Now let's take a better look at the attributes of the <bgsound> tag :

src - path to your audio file
loop - how many times to repeat the melody (if -1, then it repeats endlessly)
balance - stereo balance value (from -10000 to 10000)
volume - the volume of the melody playing, where 0 is the maximum, and -10000 is the minimum.

But, there will be no way to control the player in any way - every time the page is updated, the track will be played again.
After describing the method of inserting background music, I want to dissuade you from this, since most users already, as a rule, listen to music at the time of visiting various sites.
So, the accompanying musical accompaniment can only force him to close the tab with website.
  •