The forum of the forums
Welcome to the Official Support Forum of Forumotion!

To take full advantage of everything offered by our forum, please log in if you are already a member, or join our community if you've not yet.



Create a free forum like this one.

background music on homepage

View previous topic View next topic Go down

Solved background music on homepage

Post by hbox on August 3rd 2015, 4:43 pm

is it possible to addbackground music to the homepage

hbox
New Member

Posts : 3
Reputation : 1
Language : english

Back to top Go down

Solved Re: background music on homepage

Post by Ange Tuteur on August 3rd 2015, 5:19 pm

Hi @hbox,

Yes it's possible with the <audio> element. Wink

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.

Ange Tuteur
Forumaster

Male Posts : 13021
Reputation : 2684
Language : EN10, FR5
Location : Pennsylvania

http://fmdesign.forumotion.com

Back to top Go down

Solved Re: background music on homepage

Post by hbox on August 11th 2015, 11:41 pm

thanks for that Hello

hbox
New Member

Posts : 3
Reputation : 1
Language : english

Back to top Go down

Solved Re: background music on homepage

Post by Ange Tuteur on August 12th 2015, 11:27 am

You're welcome ^^

Topic archived

If you have anymore problems feel free to open a new topic. Smile

Ange Tuteur
Forumaster

Male Posts : 13021
Reputation : 2684
Language : EN10, FR5
Location : Pennsylvania

http://fmdesign.forumotion.com

Back to top Go down

View previous topic View next topic Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum