Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-05-2012, 07:50 AM   PM User | #1
keerthy
New to the CF scene

 
Join Date: Dec 2011
Location: india
Posts: 6
Thanks: 6
Thanked 0 Times in 0 Posts
keerthy is an unknown quantity at this point
Smile How to add background music to my webpage

How to add an .mp3 file using java-script with HTML.

I wish to add an mp3 file as a background music to my webpage. It should load automatically while user viewing my home page.

I'm doing a project in php.

"Give me a simple and easiest guideline for me"

-thank you
keerthy is offline   Reply With Quote
Old 01-05-2012, 07:55 AM   PM User | #2
Philip M
Supreme Master coder!

 
Philip M's Avatar
 
Join Date: Jun 2002
Location: London, England
Posts: 17,033
Thanks: 197
Thanked 2,410 Times in 2,388 Posts
Philip M has a spectacular aura aboutPhilip M has a spectacular aura aboutPhilip M has a spectacular aura about
Google is your friend! Adding music to a webpage is a cross-browser minefield, and if it is made to play automatically will probably annoy your visitors and drive them away. What if they are playing music already when they arrive at your site?

Have a look at

http://www.frontpagewebmaster.com/m-.../tm.htm#189647

and take the advice offered!!

All advice is supplied packaged by intellectual weight, and not by volume. Contents may settle slightly in transit.
__________________

All the code given in this post has been tested and is intended to address the question asked.
Unless stated otherwise it is not just a demonstration.

Last edited by Philip M; 01-05-2012 at 08:09 AM..
Philip M is offline   Reply With Quote
Users who have thanked Philip M for this post:
keerthy (01-06-2012)
Old 01-05-2012, 08:18 AM   PM User | #3
chump2877
Senior Coder

 
chump2877's Avatar
 
Join Date: Dec 2004
Location: the U.S. of freakin' A.
Posts: 2,530
Thanks: 15
Thanked 128 Times in 121 Posts
chump2877 is on a distinguished road
I agree with Phillip -- adding background music to your site is usually a terrible idea.

That said, the new HTML5 "audio" tag is another possibility.

Also check out: http://www.html5rocks.com/en/tutorials/webaudio/intro/
__________________
Regards, R.J.
chump2877 is offline   Reply With Quote
Users who have thanked chump2877 for this post:
keerthy (01-06-2012)
Old 01-05-2012, 08:39 AM   PM User | #4
Philip M
Supreme Master coder!

 
Philip M's Avatar
 
Join Date: Jun 2002
Location: London, England
Posts: 17,033
Thanks: 197
Thanked 2,410 Times in 2,388 Posts
Philip M has a spectacular aura aboutPhilip M has a spectacular aura aboutPhilip M has a spectacular aura about
Quote:
Originally Posted by chump2877 View Post
That said, the new HTML5 "audio" tag is another possibility.
Even that is a nightmare! The MP3 file format is supported by
Internet Explorer 9, Google Chrome 6 and Apple Safari 5, but NOT by
Firefox 4.0 or Opera 10.6
Aaaarrrggghhh!
__________________

All the code given in this post has been tested and is intended to address the question asked.
Unless stated otherwise it is not just a demonstration.
Philip M is offline   Reply With Quote
Users who have thanked Philip M for this post:
keerthy (01-06-2012)
Old 01-05-2012, 09:00 AM   PM User | #5
chump2877
Senior Coder

 
chump2877's Avatar
 
Join Date: Dec 2004
Location: the U.S. of freakin' A.
Posts: 2,530
Thanks: 15
Thanked 128 Times in 121 Posts
chump2877 is on a distinguished road
Well if you have to use audio (or video) in a site, that would appear to be the way to do it moving forward. The best way to fight cross-browser issues is to implement a standards-based approach.
__________________
Regards, R.J.
chump2877 is offline   Reply With Quote
Users who have thanked chump2877 for this post:
keerthy (01-06-2012)
Old 01-06-2012, 03:09 PM   PM User | #6
keerthy
New to the CF scene

 
Join Date: Dec 2011
Location: india
Posts: 6
Thanks: 6
Thanked 0 Times in 0 Posts
keerthy is an unknown quantity at this point
thanks for your tips n guidelines
keerthy is offline   Reply With Quote
Old 12-20-2012, 04:58 AM   PM User | #7
candi
New to the CF scene

 
Join Date: Dec 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
candi is an unknown quantity at this point
background music

Hello,

I have background music on this website: beauty-4-ashes-outreach.org. I want to know if there is another code to use to have the music to play visiting the site from a cellphone and or tablet?

The code I had that didn't work was:
<object type="audio/mp3"
data=".mpg">
<param name="autoplay"
value="false">
</object>

Also, for it to be cross browsers.

She wants to have music on her site

Thanks in advance
candi is offline   Reply With Quote
Old 12-20-2012, 07:45 AM   PM User | #8
Philip M
Supreme Master coder!

 
Philip M's Avatar
 
Join Date: Jun 2002
Location: London, England
Posts: 17,033
Thanks: 197
Thanked 2,410 Times in 2,388 Posts
Philip M has a spectacular aura aboutPhilip M has a spectacular aura aboutPhilip M has a spectacular aura about
Quote:
Originally Posted by candi View Post
Hello,

I have background music on this website: beauty-4-ashes-outreach.org. I want to know if there is another code to use to have the music to play visiting the site from a cellphone and or tablet?

The code I had that didn't work was:
<object type="audio/mp3"
data=".mpg">
<param name="autoplay"
value="false">
</object>

Also, for it to be cross browsers.

She wants to have music on her site

Thanks in advance
Please see the previous answers posted in this thread.
One more time - adding background music to your site is usually a terrible idea.
Especially for mobile devices.
__________________

All the code given in this post has been tested and is intended to address the question asked.
Unless stated otherwise it is not just a demonstration.
Philip M is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 12:26 PM.


Advertisement
Log in to turn off these ads.