473,320 Members | 1,802 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Music in background w/ onload, function, or any other method.

Death Slaught
1,137 1GB
I need a function that plays a song in the background ( in other words the user can't stop/start the music they have to go to another page or listen to it )

I'm not the greatest at JavaScript I don't do much with it, but I'm hoping to change that.

It doesn't really make a difference if you can do it wile the page is loading or it starts when the page is completely loaded.

Thanks, Death
Sep 14 '07 #1
11 10784
acoder
16,027 Expert Mod 8TB
That would be annoying, but here's a link.
Sep 15 '07 #2
Death Slaught
1,137 1GB
That would be annoying, but here's a link.
The type of site I'm making, the users will expect music, so it wont be "annoying", and I've been to w3schools, already thats why I'm asking for a way to put it into a function.

Thanks anyway, Death
Sep 17 '07 #3
acoder
16,027 Expert Mod 8TB
The type of site I'm making, the users will expect music, so it wont be "annoying"
Maybe that should've been "could be".

I don't play much with sound, but you could try using an iframe linked to a sound file. Do you mind the sound player showing on the screen?
Sep 18 '07 #4
Death Slaught
1,137 1GB
Maybe that should've been "could be".

I don't play much with sound, but you could try using an iframe linked to a sound file. Do you mind the sound player showing on the screen?
Yea I wan't it to be in the background.

Thanks, Death
Sep 18 '07 #5
acoder
16,027 Expert Mod 8TB
Yea I wan't it to be in the background.

Thanks, Death
Have a play with this. Instead of playing using a button, you could add it onload.
Sep 19 '07 #6
Death Slaught
1,137 1GB
Have a play with this. Instead of playing using a button, you could add it onload.
Thanks, but it's still not what I'm looking for, I wan't the music to play in the background yes, but I wan't it in a JavaScript function, onload would be fine as long as it's something like this. (no this doesn't work it's just something i've tried).



Expand|Select|Wrap|Line Numbers
  1. function play()
  2.  
  3. {
  4. window.bgsound="location";
  5. }

[HTML]<body onload="play()">
</body>[/HTML]

Thanks again, Death
Sep 19 '07 #7
acoder
16,027 Expert Mod 8TB
Thanks, but it's still not what I'm looking for, I wan't the music to play in the background yes, but I wan't it in a JavaScript function, onload would be fine as long as it's something like this. (no this doesn't work it's just something i've tried).
Have you tried something like this:
Expand|Select|Wrap|Line Numbers
  1. function play() {
  2. embed = document.createElement("embed");
  3. embed.setAttribute("src", "soundfile.wav");
  4. embed.setAttribute("hidden", true);
  5. embed.setAttribute("autostart", true);
  6. document.body.appendChild(embed);
  7. }
and call it onload.
Sep 20 '07 #8
Jeez okay, the last reply was probably the best recommendation. But just a few issues with making music play in the background:
1. It must not be copyrighted, or you must be the owner.
2. You better put play/pause and next/previous button, or else your users will get annoyed with the music constantly playing and restarting every time they refresh.
3. Although your users will expect to hear music, your looking at a rare audience. What about visitors? Stumblers? They have no idea your site will play music, unless you put "THIS SITE PLAYS MUSIC" in your title tag :)
Good luck.
Sep 20 '07 #9
Death Slaught
1,137 1GB
Have you tried something like this:
Expand|Select|Wrap|Line Numbers
  1. function play() {
  2. embed = document.createElement("embed");
  3. embed.setAttribute("src", "soundfile.wav");
  4. embed.setAttribute("hidden", true);
  5. embed.setAttribute("autostart", true);
  6. document.body.appendChild(embed);
  7. }
and call it onload.
Thanks just what I needed.

- Death
Sep 20 '07 #10
acoder
16,027 Expert Mod 8TB
Jeez okay, the last reply was probably the best recommendation. But just a few issues with making music play in the background:
1. It must not be copyrighted, or you must be the owner.
2. You better put play/pause and next/previous button, or else your users will get annoyed with the music constantly playing and restarting every time they refresh.
3. Although your users will expect to hear music, your looking at a rare audience. What about visitors? Stumblers? They have no idea your site will play music, unless you put "THIS SITE PLAYS MUSIC" in your title tag :)
Good luck.
Good points. I'd say a pause/stop button wouldn't do any harm.
Sep 21 '07 #11
acoder
16,027 Expert Mod 8TB
Thanks just what I needed.

- Death
Glad to hear you got it working. Remember to take care with sound.
Sep 21 '07 #12

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Alistair Birch | last post by:
Hi I want rows of a table to appear in alternating background colours. Having looked around the web I can't find any solution apart from waiting for the next version of CSS, so I tried building...
11
by: Konrad Den Ende | last post by:
I have a function returning a string but the problem is that the color of it is blue which suits me well for some pages but not for others. Is it possible to "feel" what the color of the background...
20
by: gallery | last post by:
Our client insists on having a music loop playing as the visitor travels throughout his new HTML website. We will not be doing this in frames and I would prefer not to have the home page spawn...
2
by: laredotornado | last post by:
Hello, I am looking for a cross-browser way (Firefox 1+, IE 5.5+) to have my Javascript function execute from the BODY's "onload" method, but if there is already an onload method defined, I would...
1
by: Gaffer | last post by:
Is it possible to change the following code so that the music is 'off' when the page is loaded and the user gets the option to turn it on? ---------------------------------------------------...
1
by: Mike | last post by:
I want to change the background image of the html page within code based on the users selection. I'm trying to use this in the page onload even response.write("<body background=' & dataitem>") ...
2
by: mstearne | last post by:
Has anyone seen any Javascript that mimics the effect that allows you to browse through the New Releases, Just Added sections of the iTunes Music Store? Where you click the arrow icon and the next...
2
by: ventsislav | last post by:
I want to have a background music to my simple app and a buton which plays another sound, but when I press the button the sound from it interrupts the background sound. I tried with SoundPlayer and...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.