You are viewing our Forum Archives. To view or take place in current topics click here.
Autoplay music in HTML help
Posted:

Autoplay music in HTML helpPosted:

Sundown
  • Rigged Luck
Status: Offline
Joined: May 29, 201014Year Member
Posts: 4,173
Reputation Power: 9399
Status: Offline
Joined: May 29, 201014Year Member
Posts: 4,173
Reputation Power: 9399
I would like to have mucic autoplay when you enter my site.

Source

[ Register or Signin to view external links. ]


I have the mp3 in my 'assets' folder

I can get the audio to work if it is an embedded link but then there is a large player at the top of the site, I don't want that.

I don't really care if there is an audio control or not I just want it to autoplay.
#2. Posted:
Large
  • Christmas!
Status: Offline
Joined: Jun 03, 201014Year Member
Posts: 2,900
Reputation Power: 3713
Status: Offline
Joined: Jun 03, 201014Year Member
Posts: 2,900
Reputation Power: 3713
change <audio> to <audio controls autoplay> and let me know what happens! also remove line 4 and tab out 5 6 and 7 looks cleaner, easier to read.
#3. Posted:
Sundown
  • Spooky Poster
Status: Offline
Joined: May 29, 201014Year Member
Posts: 4,173
Reputation Power: 9399
Status: Offline
Joined: May 29, 201014Year Member
Posts: 4,173
Reputation Power: 9399
Audio control appears but no audio :/

[ Register or Signin to view external links. ]
#4. Posted:
Large
  • TTG Addict
Status: Offline
Joined: Jun 03, 201014Year Member
Posts: 2,900
Reputation Power: 3713
Status: Offline
Joined: Jun 03, 201014Year Member
Posts: 2,900
Reputation Power: 3713
Sundown wrote Audio control appears but no audio :/

[ Register or Signin to view external links. ]


keep what i previously posted but change <source src=ChildishGambinoClxmaxCut.mp3" type"audio/mpeg">

to

<source src=/assests/ChildishGambinoClxmaxCut.mp3" type"audio/mpeg">
#5. Posted:
Sundown
  • Winter 2023
Status: Offline
Joined: May 29, 201014Year Member
Posts: 4,173
Reputation Power: 9399
Status: Offline
Joined: May 29, 201014Year Member
Posts: 4,173
Reputation Power: 9399
Same thing happened :/

Player appears but not able to click play or anything

[ Register or Signin to view external links. ]
#6. Posted:
-Deano
  • PC Master Race
Status: Offline
Joined: Aug 19, 201014Year Member
Posts: 5,243
Reputation Power: 532
Status: Offline
Joined: Aug 19, 201014Year Member
Posts: 5,243
Reputation Power: 532
Sundown wrote Same thing happened :/

Player appears but not able to click play or anything

[ Register or Signin to view external links. ]


You said your folder was called "assets". Change your src attribute to match it accordingly.
You are also missing your first quote mark for the src attribute.

<source src="assets/ChildishGambinoxmaxCut.mp3" type="audio/mpeg">
#7. Posted:
ecco2k
  • TTG Master
Status: Offline
Joined: Oct 22, 201014Year Member
Posts: 830
Reputation Power: 458
Status: Offline
Joined: Oct 22, 201014Year Member
Posts: 830
Reputation Power: 458
Well, your code is all over the place so let me help you out.

[ Register or Signin to view external links. ]

As you can see, I have sorted your code into a more easier format which makes it easier to understand what is happening on the page. You don't have to follow this but from my experience as a web developer creating a standard for yourself to code by helps you a lot more if you want to come back to something or even continue working on your work the next day.

Hope I helped!
#8. Posted:
_Ashwee
  • Junior Member
Status: Offline
Joined: Apr 09, 20168Year Member
Posts: 54
Reputation Power: 3
Status: Offline
Joined: Apr 09, 20168Year Member
Posts: 54
Reputation Power: 3
Just wondering but why on line 3 is there a randomly placed </audio> ??
#9. Posted:
j0sh
  • Resident Elite
Status: Offline
Joined: Sep 01, 201410Year Member
Posts: 268
Reputation Power: 15
Status: Offline
Joined: Sep 01, 201410Year Member
Posts: 268
Reputation Power: 15
You must use the correct attributes in your <audio> tag(s). Also, as _Ashwee said:

_Ashwee wrote Just wondering but why on line 3 is there a randomly placed </audio> ??


You have to make sure you don;t have random tags anywhere. To ensure there aren;t any other random tags floating about, becauee I assume that is just a snippet of your page, youcan use the W3 validator, [ Register or Signin to view external links. ] . But then again, your webpage must be uploaded to a server/domain.

You can use this code to fix your problem:


<audio controls autoplay>
  <source src="path/to/sound.ogg" type="audio/ogg">
  Your browser does not support the audio element.
</audio>


You can read W3Schools on more information about the audio tags: [ Register or Signin to view external links. ]
#10. Posted:
Rizzah
  • V5 Launch
Status: Offline
Joined: Dec 19, 201410Year Member
Posts: 1,783
Reputation Power: 102
Status: Offline
Joined: Dec 19, 201410Year Member
Posts: 1,783
Reputation Power: 102
I am doing a new site, to get the mp3 file to play consistently without a control panel use this code.

<audio autoplay loop>
<source src="your song" type="audio/ogg">
<source src="Your song.mp3" type="audio/mpeg">
</audio>
Jump to:
You are viewing our Forum Archives. To view or take place in current topics click here.