Help with Javascript + embed tag.

Discussion in 'Web Design and Development' started by deputy_doofy, Dec 25, 2006.

  1. deputy_doofy macrumors 65816

    deputy_doofy

    Joined:
    Sep 11, 2002
    #1
    Ok, here's the deal. I made a new version of Scriptris, a javascript Tetris clone. I tried adding music by putting a drop-down menu in and letting the user select the tune.
    It works in FireFox (Mac) and Safari.

    It does NOT work in IE 7.x, nor FireFox (Win).
    In IE7, if I change the song, it simply plays the new song over the previous one, and I can get the same tunes all playing simultaneously, which results in an ugly mess. As you can guess, the off option doesn't work at all.
    In FF (Win), I get a message saying that it is missing a plug-in and never plays anything. It can't find any plug-ins automatically so I'm not sure what's needed. It already has QT 7.1.3 installed. What more do I need to get FF (Win) to play a quicktime sound?

    You can test it here... http://mywebpages.comcast.net/skull2k5/scriptris2_0.html

    The function that creates and removes the embed tag is:
    function playTune(tune)
    // tune variable is sent from a select tag.
    {
    // Create url based on tune selected.
    var url="./music/tune"+tune.value+".mp3";
    // Create reference pointer to embed tag.
    var tetrisTune=document.getElementById("tetris_tune");
    // Security check in case no embed tag exists.
    if (tetrisTune==null && tune.value=="0") return;
    // As long as tetrisTune reference exists...
    if (tetrisTune!=null)
    {
    // Stop existing tune and remove embed node from document.
    tetrisTune.Stop();
    document.body.removeChild(tetrisTune);
    }
    // Create brand new embed node and set attributes for that tag.
    tetrisTune=document.createElement("embed");
    tetrisTune.setAttribute("loop","true");
    tetrisTune.setAttribute("hidden","true");
    tetrisTune.setAttribute("autostart","true");
    tetrisTune.setAttribute("src",url);
    tetrisTune.setAttribute("id","tetris_tune");
    tetrisTune.setAttribute("enablejavascript","true");
    document.body.appendChild(tetrisTune);
    }// end playTune
     
  2. deputy_doofy thread starter macrumors 65816

    deputy_doofy

    Joined:
    Sep 11, 2002
    #2
    Well, one problem fixed. By adding a type="video/quicktime" attribute/value, it now works in Windows FireFox.
    IE is still goofy, with it overlapping tunes. Well, at least the game works. :D
     

Share This Page