is it possible to add background music to the homepage
2 posters
background music on homepage
Ange Tuteur- Forumaster
- Posts : 13207
Reputation : 3000
Language : English & 日本語
Location : Pennsylvania
- Post n°2
Re: background music on homepage
Hi @hbox,
Yes it's possible with the <audio> element.
Go to Administration Panel > Modules > JavaScript codes management and create a new script.
Placement : In the homepages
Paste the following code :
There are a few things to modify :
loop : if set to true the audio will loop when it ends, otherwise set it to false so it does not loop.
autoplay : when set to true the audio will automatically play.
controls : currently set to false, but if set to true it will show the player controls.
Lastly you'll see source and inside it : mp3, ogg, and wav. Between the empty quotes you should link to the music file and place it under the correct extension. For example, if the file link ends in .mp3 it should go in the mp3 slot.
Yes it's possible with the <audio> element.
Go to Administration Panel > Modules > JavaScript codes management and create a new script.
Placement : In the homepages
Paste the following code :
- Code:
$(function() {
var audio = {
loop : true,
autoplay : true,
controls : false,
source : {
mp3 : '',
ogg : '',
wav : ''
}
},
node = document.createElement('AUDIO'), i, j, src;
for (i in audio) {
if (audio[i].constructor != Object) node[i] = audio[i];
else {
for (j in audio[i]) {
if (audio[i][j]) {
src = document.createElement('SOURCE');
src.src = audio[i][j];
src.type = 'audio/' + (j == 'mp3' ? 'mpeg' : j);
node.appendChild(src);
}
}
}
}
document.body.appendChild(node);
'par ange tuteur';
});
There are a few things to modify :
loop : if set to true the audio will loop when it ends, otherwise set it to false so it does not loop.
autoplay : when set to true the audio will automatically play.
controls : currently set to false, but if set to true it will show the player controls.
Lastly you'll see source and inside it : mp3, ogg, and wav. Between the empty quotes you should link to the music file and place it under the correct extension. For example, if the file link ends in .mp3 it should go in the mp3 slot.
hbox- New Member
- Posts : 3
Reputation : 1
Language : english
- Post n°3
Re: background music on homepage
thanks for that
Ange Tuteur- Forumaster
- Posts : 13207
Reputation : 3000
Language : English & 日本語
Location : Pennsylvania
- Post n°4
Re: background music on homepage
You're welcome ^^
Topic archived
If you have anymore problems feel free to open a new topic.
Topic archived
If you have anymore problems feel free to open a new topic.