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
11 10784
That would be annoying, but here's a link.
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
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?
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
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.
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). - function play()
-
-
{
-
window.bgsound="location";
-
}
[HTML]<body onload="play()">
</body>[/HTML]
Thanks again, Death
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: - function play() {
-
embed = document.createElement("embed");
-
embed.setAttribute("src", "soundfile.wav");
-
embed.setAttribute("hidden", true);
-
embed.setAttribute("autostart", true);
-
document.body.appendChild(embed);
-
}
and call it onload.
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.
Have you tried something like this: - function play() {
-
embed = document.createElement("embed");
-
embed.setAttribute("src", "soundfile.wav");
-
embed.setAttribute("hidden", true);
-
embed.setAttribute("autostart", true);
-
document.body.appendChild(embed);
-
}
and call it onload.
Thanks just what I needed.
- Death
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.
Thanks just what I needed.
- Death
Glad to hear you got it working. Remember to take care with sound.
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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...
|
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...
|
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...
|
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?
---------------------------------------------------...
|
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>")
...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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)...
|
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...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
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....
| | |