Background Sound in HTML / Javascript

Discussion in 'Javascript' started by Gil, Nov 27, 2003.

  1. Gil

    Gil Guest

    I'm trying to write a page that allows me to change the background
    midi that's playing.

    I've been going crazy consulting Google Groups, and coming up with
    ingenious solutions, some of which kind of work in some situations.
    I'm quite prepared to implement a number of solutions simultaneously
    and browser-distinguish to select the right one, but it's hard even to
    find the criteria that decide what works in which browser.

    I'd be grateful for any advice.

    Solution 1 - which looks the cleanest. It works with some IEs -
    5.00.2614.3500IS in particular

    I put all the desired midis in the body of the page as EMBEDs, with
    name properties, then when I want to change the tune, I call a
    Javascript function,

    function newsong(newname)
    {
    for (var ii=0; ii < document.embeds.length; ii++)
    {
    if (oldname == document.embeds[ii].name)
    {
    document.embeds[ii].stop();
    break;
    }
    }

    for (var ii=0; ii < document.embeds.length; ii++)
    {
    if (newname == document.embeds[ii].name)
    {
    document.embeds[ii].play();
    break;
    }
    }
    oldname = newname;
    }

    Example http://www.amazonsystems.co.uk/bridge/Page1.htm - The Save
    button changes the tune in theory.

    Solution 2 - Messy but straightforward - this works with Netscape 4.08
    and with IE 5.00.2614.3500IS, but not 5.00.2614.3500

    Again, I include and name all the EMBEDs (I have to have MASTERSOUND
    for Netscape to work.)

    function newsong(newname)
    {
    document.embedname1.stop();
    document.embedname2.stop();
    document.embedname3.stop();
    ....etc.
    if (newname == embedname1) document.embedname1.play();
    else if (newname == embedname2) document.embedname2.play();
    else if (newname == embedname3) document.embedname3.play();
    else if (newname == embedname4) document.embedname4.play();
    ....etc

    Example http://www.amazonsystems.co.uk/bridge/Page2.htm - The Save
    button changes the tune in theory.


    Solution 3 - Messier still - have a separate tiny html page for each
    midi, and call it up when required, without releasing the original
    page. It seems easier to build a page that works everywhere if you
    don't need to change the background sound.

    I haven't implemented that, but it's ghastly.

    Gil
    Gil, Nov 27, 2003
    #1
    1. Advertising

  2. Gil

    Gil Guest

    (Gil) wrote in message news:<>...
    > I'm trying to write a page that allows me to change the background
    > midi that's playing.
    >

    etc....

    Oh, and I'm now working on Solution 4 that puts static BGSOUND / EMBED
    for each song in a separate, otherwise empty HTML file, with the
    intention of putting the tune in a tiny frame <spit>, and the other
    stuff in the main frame, changing the contents of the tiny frame,
    rather than trying to change the tune in the main frame.... wish me
    luck. I've never been reduced to using frames before.

    Gil
    Gil, Nov 27, 2003
    #2
    1. Advertising

  3. Gil

    Paul Cooper Guest

    On 27 Nov 2003 07:41:36 -0800, (Gil) wrote:

    > (Gil) wrote in message news:<>...
    >> I'm trying to write a page that allows me to change the background
    >> midi that's playing.
    >>

    >etc....
    >
    >Oh, and I'm now working on Solution 4 that puts static BGSOUND / EMBED
    >for each song in a separate, otherwise empty HTML file, with the
    >intention of putting the tune in a tiny frame <spit>, and the other
    >stuff in the main frame, changing the contents of the tiny frame,
    >rather than trying to change the tune in the main frame.... wish me
    >luck. I've never been reduced to using frames before.
    >
    >Gil



    Surely it should be <spit/> or <spit></spit>!

    Paul
    Paul Cooper, Nov 27, 2003
    #3
  4. Gil

    Gil Guest

    Gil, Nov 27, 2003
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Luc The Perverse

    Sound Quality In Sound API

    Luc The Perverse, Oct 30, 2005, in forum: Java
    Replies:
    4
    Views:
    1,483
    Andrew Thompson
    Oct 31, 2005
  2. Replies:
    0
    Views:
    504
  3. P.o.l

    xhtml VS background sound

    P.o.l, Jun 14, 2004, in forum: HTML
    Replies:
    4
    Views:
    487
    Psyonicdreams
    Jun 14, 2004
  4. Dung Ping

    Background sound for IE and FF

    Dung Ping, Dec 27, 2005, in forum: HTML
    Replies:
    5
    Views:
    4,650
    Dung Ping
    Dec 29, 2005
  5. Jeff Dillon

    Background Sound

    Jeff Dillon, Aug 15, 2008, in forum: ASP .Net
    Replies:
    2
    Views:
    352
    Jeff Dillon
    Aug 15, 2008
Loading...

Share This Page