Jump to content

  •  

- - - - -

How to add music in background html


  • Please log in to reply
2 replies to this topic

#1 stnalex

stnalex

    Newbie

  • Member
  • Pip
  • 7 posts

Posted 25 February 2019 - 10:40 PM

IF YOU WANT TO ADD MUSIC IN BACKGROUND HTML YOU CAN USE THAT:

First, you need to create a folder named 'music' or whatever you want.

Then create a text file where you will need  to put the code you see down there.

After that, change from .txt to .html and finish.
///
Or add this code to your .html file

THIS ONE WORKS FOR EVERY BROWSER

<embed src="music.mp3" autostart="true" loop="true"
width="2" height="0">
</embed>


THIS ONE WORKS FOR PERFORMANT BROWSERS (opera, chrome, etc)

<embed src="music.mp3" autostart="true" loop="true"
width="2" height="0">
</embed>
<noembed>
<bgsound src="music.mp3" loop="infinite">
</noembed>


I hope it works for you.

#2 PurplePhase

PurplePhase

    Newbie

  • Member
  • Pip
  • 7 posts

Posted 06 June 2019 - 07:27 AM

Without adding javascript, is it possible to make it so multiple songs could load, and have the ability to change them?

#3 tamiko

tamiko

    Newbie

  • Member
  • Pip
  • 3 posts
  • LocationSpace

Posted 20 June 2019 - 07:58 PM

View PostPurplePhase, on 06 June 2019 - 07:27 AM, said:

Without adding javascript, is it possible to make it so multiple songs could load, and have the ability to change them?

you cannot do that as html is a markup language and scripting would require javascript as such

let audio = new Audio('audio minecraftTheme.mp3');
audio.play(); // this will play only a single file while we can do is add a for each loop checking for *.mp3 add that to a array then play audio after audio is finished





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users