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 10794 acoder 16,027
Recognized Expert Moderator MVP
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
acoder 16,027
Recognized Expert Moderator MVP
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
acoder 16,027
Recognized Expert Moderator MVP
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
acoder 16,027
Recognized Expert Moderator MVP
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
acoder 16,027
Recognized Expert Moderator MVP
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.
acoder 16,027
Recognized Expert Moderator MVP
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: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| | |