How do I make a web page that plays sound upon page load?
Asked by
fireside (
12359)
October 8th, 2008
This is for the highly practical application of playing audio files with my linked comments on Fluther…
I use php on my site.
Observing members:
0
Composing members:
0
12 Answers
Stick this in your <body> tag: <embed src=“THE NAME OF YOUR FILE.mp3” autostart=true width=0 height=0>
And I if just wanted a blank page with the audio, I could use the same tag without the <body> tag, or no?
You don’t, as this is considered horrible nettiquette. Put a play button on the page!
@fireside You can have body tags and still have no content displayed. But I do believe that it would work without <body> tags.
I agree with tonedef – this is a horrible practice. You should give the visitors an option to play, with the music turned off from get go.
@anaphase – That is so cool you know how to do that BAM just like that. lurve.
It is horrible netiquette to have anything play on page load. The only way you would be able to offset this flagrant disregard of Internet rules is to make sure you include no less then 15 dancing baby gifs somewhere on the page.
ooo, dancing baby gifs!!!
Good idea!
got to work now, but will try something out later tonight if possible. thanks everyone
Seriously though, if you don’t mind doing a little reading I would suggest this article which explains building a pop up mp3 player that the user can shut off. I think it comes across as being pretty slick without any fancy coding.
There’s links to some other articles in there which have different methods for building players.
Keep your bandwidth in mind. The reason that a lot of old sites would use midis in the background is because you didn’t have to stream a very large file to all your users. Once you start streaming an mp3, assuming you’re on a basic shared server webhosting, you’ll be able to stream the audio to maybe five or ten people at the same time before it starts to crack and sputter (for everyone).
If you’re hosting the webserver on Apache at your own house, it might be less then that.
If you just want a blank page with audio, you might as well just provide a link directly to the MP3 file. Let the user and their computer decide how it displays and plays.
Answer this question