background music on homepage Hitskin_logo Hitskin.com

This is a Hitskin.com skin preview
Install the skinReturn to the skin page

The forum of the forums
Would you like to react to this message? Create an account in a few clicks or log in to continue.
2 posters

    background music on homepage

    avatar
    hbox
    New Member


    Posts : 3
    Reputation : 1
    Language : english

    Solved background music on homepage

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

    is it possible to add background music to the homepage
    Ange Tuteur
    Ange Tuteur
    Forumaster


    Male Posts : 13207
    Reputation : 3000
    Language : English & 日本語
    Location : Pennsylvania

    Solved Re: background music on homepage

    Post by Ange Tuteur 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.
    avatar
    hbox
    New Member


    Posts : 3
    Reputation : 1
    Language : english

    Solved Re: background music on homepage

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

    thanks for that  Hello
    Ange Tuteur
    Ange Tuteur
    Forumaster


    Male Posts : 13207
    Reputation : 3000
    Language : English & 日本語
    Location : Pennsylvania

    Solved Re: background music on homepage

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

    You're welcome ^^

    Topic archived

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