JavaScript Tip of the Week for September 16, 1996: Much Ado About LiveConnect | Source Code | WebReference

JavaScript Tip of the Week for September 16, 1996: Much Ado About LiveConnect | Source Code

JavaScript Tip of the Weekfor September 16, 1996: Source Code: Much Ado About LiveConnect

JavaScript and Plugins
JavaScript and Java



Use embeds like these anywhere in the page to create playable LiveAudio controls:

<EMBED SRC = "classic.mid" 
 HIDDEN = TRUE
 CONTROLS = console
 VOLUME = 100 
 LOOP = FALSE 
 AUTOSTART = FALSE
 NAME = "classic" 
 MASTERSOUND>
<EMBED SRC = "jazz.mid" 
 HIDDEN = TRUE
 CONTROLS = console
 VOLUME = 100 
 LOOP = FALSE 
 AUTOSTART = FALSE
 NAME = "jazz" 
 MASTERSOUND>
<EMBED SRC = "click.au" 
 HIDDEN = TRUE
 CONTROLS = console
 VOLUME = 75 
 LOOP = FALSE 
 AUTOSTART = FALSE
 NAME = "click" 
 MASTERSOUND>


Control them with these functions:

    document.embed_name.play(false);
    document.embed_name.stop();            
    document.embed_name.pause();          
Here's The code I used to create my little LiveConect App:

function play(which)
{
if (document.embeds[0] == null           || 
    document.embeds[1] == null           || 
    document.embeds[2] == null           || 
    document.embeds[0].IsReady() != true ||
    document.embeds[1].IsReady() != true ||
    document.embeds[2].IsReady() != true  )
{
alert("Please wait for a moment while the sound files load.");
history.go(0);
return;
}
        if (which == 1) 
        {
                if (classic == false)  
                {
                document.classic.play(false);
                document.images[1].src = con.src;
                document.images[2].src = joff.src;
                document.images[3].src = poff.src;
                pauset = false;
                classic = true;
                classicp = false;
                jazz = false;
                jazzp = false;
                }
                else if (classic == true)  
                {
                document.classic.stop();
                document.images[1].src = coff.src;
                classic = false;
                }
        }
        if (which == 2) 
        {
                if (jazz == false)  
                {
                document.jazz.play(false);
                document.images[2].src = jon.src;
                document.images[1].src = coff.src;
                document.images[3].src = poff.src;
                pauset = false;
                jazz = true;
                jazzp = false;
                classic = false; 
                classicp = false;
                }
                else if (jazz == true)  
                {
                document.jazz.stop();
                document.images[2].src = joff.src;
                jazz = false;
                }
        }        
document.click.play(false);
}
function pause()
{
        if (pauset == false)
        {
                if (jazz == true)
                {        
                document.jazz.pause();
                document.images[2].src = joff.src;
                jazzp = true;
                }
                if (classic == true)
                {        
                document.classic.pause();
                document.images[1].src = coff.src;
                classicp = true;
                }
        document.images[3].src = pon.src;
        pauset = true;
        }
        else if (pauset == true)
        {
                if (jazzp == true)
                {        
                document.jazz.pause();
                document.images[2].src = jon.src;
                jazz = true;
                jazzp = false;
                }
       
                if (classicp == true)
                {        
                document.classic.pause();
                document.images[1].src = con.src;
                classic = true;
                classicp = false;
                }
        document.images[3].src = poff.src;
        pauset = false;
        }
document.click.play(false);
}
<TABLE BORDER = 0 CELLPADDING = 0 CELLSPACING = 0>
<TR><TD>
<A HREF = "javascript:play(1);">
<IMG BORDER = 0 HEIGHT = 34 WIDTH = 59 SRC = "classicoff.gif"></A>
</TD><TD>
<A HREF = "javascript:play(2);">
<IMG BORDER = 0 HEIGHT = 34 WIDTH = 59 SRC = "jazzoff.gif"></A>
</TD><TD>
<A HREF = "javascript:pause();">
<IMG BORDER = 0 HEIGT = 34 WIDTH = 59 SRC = "pauseoff.gif"></A>
</TD></TR></TABLE>


Put this code in the head of your page to detect the screen height and width:
    if (navigator.javaEnabled())