SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Hybrid View

  1. #1
    SitePoint Member
    Join Date
    Feb 2003
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    playing music one after another

    Hi, I currently use the embed script to play music for my music box

    i wonder if there's a way to allow a continuous play of all the songs (.mid files) in the directory. so after it played one .mid, it goes to another. i currently use php to read the contents of the directory. i can get an array of all the .mid names.

  2. #2
    ♪♪ ♪ ♪ ♪ ♪♪ ♪ ♪♪ Markdidj's Avatar
    Join Date
    Sep 2002
    Location
    Bournemouth, South UK
    Posts
    1,551
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Found this on my travels

    Code:
    <head>
    <script>
    function play() { 
    setTimeout("document.location='http://www.transload.net/~tyhart/audio/moon_river.mid';",5000); 
    setTimeout("document.location='http://www.transload.net/~tyhart/audio/puff.mid';",67000); 
    setTimeout("document.location='http://www.transload.net/~tyhart/audio/amazinggrace.mid';",231000); 
    setTimeout("document.location='http://www.transload.net/~tyhart/audio/auld.mid';",390000); 
    setTimeout("document.location='http://www.transload.net/~tyhart/audio/auldlangsyne.mid';",455000); 
    setTimeout("document.location='http://www.transload.net/~tyhart/audio/thepartysover.mid';",534000); }
    play();
    </script>
    </head>
    Found that on my travels, should be of help, but you must know the length of each track. Have found others, gonna check my files. I'm looking for one that I can overlap sounds, found one but seems only to work on my computer. There are quite a few scripts that let you control sound, but usually only one at a time, which is OK for you. I'll have a look for more........
    LiveScript: Putting the "Live" Back into JavaScript
    if live output_as_javascript else output_as_html end if

  3. #3
    ♪♪ ♪ ♪ ♪ ♪♪ ♪ ♪♪ Markdidj's Avatar
    Join Date
    Sep 2002
    Location
    Bournemouth, South UK
    Posts
    1,551
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Another....

    Here's another function taht lets you start and stop music
    (1 at a time)
    <SCRIPT LANGUAGE="JavaScript">

    var NSsound = navigator.plugins && navigator.plugins["LiveAudio"];
    var IEsound = navigator.plugins && document.all;
    var audioEnabled = NSsound || IEsound;

    function playIt() {
    if (!navigator.javaEnabled()) return;
    if (!audioEnabled) return;
    if (IEsound) document.audiopanel.play()
    else if (NSsound) document.audiopanel.play(true);
    }

    function stopIt() {
    if (!navigator.javaEnabled()) return;
    if (!audioEnabled) return;
    document.audiopanel.stop();
    }

    </SCRIPT>
    <EMBED NAME=audiopanel SRC=aladdin.mid MASTERSOUND HEIGHT=60 WIDTH=144 HIDDEN=false>
    <INPUT TYPE="button" VALUE="play" onClick="playIt()">
    <INPUT TYPE="button" VALUE="Stop" onClick="stopIt()">
    LiveScript: Putting the "Live" Back into JavaScript
    if live output_as_javascript else output_as_html end if

  4. #4
    ♪♪ ♪ ♪ ♪ ♪♪ ♪ ♪♪ Markdidj's Avatar
    Join Date
    Sep 2002
    Location
    Bournemouth, South UK
    Posts
    1,551
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Also this

    Try this, putting your own midi file in. Found it the other day, but cab't find the page again. Very good one as it will let you stop, start, pause, start at position etc....
    loads of good functions
    Code:
    <HTML>
    <HEAD>
    <TITLE>Sounder</title>
    <STYLE TYPE="text/css">
    <!--
    FORM.tb {display:inline;}
      .twidth{width:100%}
      .include{ font-size: 75%; font-family: verdana, arial, helvetica;}
      .includebig{font-family: verdana, arial, helvetica;}
      .includebig A:link { color: blue; }
      .includebig A:visited { color: purple; }
      .include  A:link { color: blue; }
      .include A:visited { color: purple; }
      .submitter { font-size: 75%; font-family: verdana, arial, helvetica; }
      .codehighlight {background:#eee}
      .WRy1{background:#fc0}
      .WRy2{background:#fff3ac}
    pre.code {color: #660099; margin-left:5%}
    address {text-align: right}
     
    
    body {background:#FFFFFF; margin-left: 5%; margin-right: 5%}
    .WRBannerCenter {margin-left:-5%; margin-right:-5%; margin-top:8px; margin-bottom:8px; text-align:center}
     
    -->
    </STYLE>
     
    </HEAD>
    <BODY BGCOLOR="#ffffff">
     
     
    <H2>Audio Control Example</H2>
    <table cellpadding=0 cellspacing=0 border=0 class=twidth>
       <tr><td valign=top><style type="text/css">
    <!--
    #WDinclude {font-size:75%; font-family:verdana, arial, helvetica}
    .WDi {font-family:verdana, arial, helvetica}
    #WDinclude A:link {color: blue}
    .WDi A:link {color:blue}
    #WDinclude A:visited {color: purple}
    .WDi A:visited {color: purple}
    .WRy1{background:#fc0} .WRy2{background:#fff3ac}
    -->
    </style>
     
           <td><img src="/art/t.gif" width=9 height=1 alt=""></td>
           <td valign=top width="99%">
     
    
    <P>Let's look at an example that demonstrates many of the LiveAudio and ActiveMovie methods. The following form lets you set several properties of the LiveAudio plug-in and ActiveMovie Control:</P>
    <SCRIPT LANGUAGE="JavaScript">
    <!--
     
    var NSsound = navigator.plugins && navigator.plugins["LiveAudio"];
    var IEsound = navigator.plugins && document.all;
    var audioEnabled = NSsound || IEsound;
     
    if (!audioEnabled) alert("Your browser cannot play sound files.");
    if (!navigator.javaEnabled()) alert("Your browser is not Java-enabled. Please edit preferences.");
     
    onload = init;
    timerID = null;
     
    function init() {
      if (!navigator.javaEnabled()) return;
      if (!audioEnabled) return;
      document.display.soundcard.value = (IEsound) ? document.audiopanel.isSoundCardEnabled() : "not supported";
      document.display.filename.value = (IEsound) ?  document.audiopanel.fileName : "not supported";
      endTime = (IEsound) ? document.audiopanel.selectionEnd : "not supported"; // global variable
      document.display.position.value = (IEsound) ? Math.floor(document.audiopanel.currentPosition) : "not supported";
      state();
    }
     
    function showPosition() {
      if (!navigator.javaEnabled()) return;
      if (!audioEnabled) return;
      document.display.position.value = (IEsound) ? Math.floor(document.audiopanel.currentPosition) : "not supported";
      setTimeout("showPosition()", 1000);
    }
     
    function playIt() {
      if (!navigator.javaEnabled()) return;
      if (!audioEnabled) return;
      if (IEsound) document.audiopanel.play()
      else if (NSsound) document.audiopanel.play(true);
      state();
      timerID = setTimeout("showPosition()", 1000);
    }
     
    function stopIt() {
      if (!navigator.javaEnabled()) return;
      if (!audioEnabled) return;
      document.audiopanel.stop();
      state();
      clearInterval(timerID);
    }
     
    function pauseIt() {
      if (!navigator.javaEnabled()) return;
      if (!audioEnabled) return;
      document.audiopanel.pause();
      state();
      clearInterval(timerID);
    }
     
    function state() {
      if (!navigator.javaEnabled()) return;
      var field = document.display.state;
      if (IEsound) {
        var cur = document.audiopanel.currentState;
        if (cur == 0) field.value = "stopped";
        if (cur == 1) field.value = "paused";
        if (cur == 2) field.value = "playing";
      }
      else if (NSsound) {
        if (document.audiopanel.IsReady()) field.value = "stopped";
        if (document.audiopanel.IsPlaying()) field.value = "playing";
        if (document.audiopanel.IsPaused()) field.value = "paused";
      }
    }
     
    function toggleControls() {
      if (!navigator.javaEnabled()) return;
      if (IEsound) 
        document.audiopanel.showControls = !document.audiopanel.showControls;
    }
     
    function startAtGivenSec(sec) {
      if (!navigator.javaEnabled()) return;
      if (IEsound) 
        document.audiopanel.selectionStart = sec
      else if (NSsound) 
             document.audiopanel.start_time(sec);
    }
     
    function stopAtGivenSec(sec) {
      if (!navigator.javaEnabled()) return;
      if (IEsound) 
        document.audiopanel.selectionEnd = sec
      else if (NSsound) 
        document.audiopanel.end_time(sec);
    }
     
    function stopAtEnd() {
      if (!navigator.javaEnabled()) return;
      if (IEsound) 
        document.audiopanel.selectionEnd = endTime
      else if (NSsound) 
        document.audiopanel.stop_at_end();
    }
     
    function decreaseVolume() {
      if (!navigator.javaEnabled()) return;
      if (IEsound) 
        document.audiopanel.volume -= 10
      else if (NSsound) 
        document.audiopanel.setvol(parseInt(document.audiopanel.GetVolume() - 10))
    }
     
    function increaseVolume() {
      if (!navigator.javaEnabled()) return;
      if (IEsound) 
        document.audiopanel.volume += 10
      else if (NSsound) 
        document.audiopanel.setvol(document.audiopanel.GetVolume() + 10)
    }
     
    function setDefaultVolume() {
      if (!navigator.javaEnabled()) return;
      if (IEsound) 
        document.audiopanel.volume = 50
      else if (NSsound) 
        document.audiopanel.setvol(50)
    }
     
    if (audioEnabled)  
      document.write("<EMBED NAME='audiopanel' SRC='aladdin.mid' MASTERSOUND HEIGHT='60' WIDTH='144' HIDDEN='false'>")
    else 
      document.write("Your browser cannot play sound files.");
     
    // -->
    </SCRIPT>
    <FORM NAME="display">
    Sound card enabled: <INPUT TYPE="text" NAME="soundcard" SIZE="14"><BR>
    State: <INPUT TYPE="text" NAME="state" SIZE="10"><BR>
    Position: <INPUT TYPE="text" NAME="position" SIZE="14"><BR>
    Filename: <INPUT TYPE="text" NAME="filename" SIZE="50"><BR>
    <INPUT TYPE="button" VALUE="play" onClick="playIt()">
    <INPUT TYPE="button" VALUE="Pause" onClick="pauseIt()">
    <INPUT TYPE="button" VALUE="Stop" onClick="stopIt()"><BR>
    <INPUT TYPE="button" VALUE="Toggle Controls" onClick="toggleControls()"><BR>
    <INPUT TYPE="button" VALUE="Start @ 10 Second" onClick="startAtGivenSec(10)">
    <INPUT TYPE="button" VALUE="Stop @ 30 Second" onClick="stopAtGivenSec(30)"><BR>
    <INPUT TYPE="button" VALUE="Start @ 0 Second" onClick="startAtGivenSec(0)">
    <INPUT TYPE="button" VALUE="Stop @ End of Track" onClick="stopAtEnd()"><BR>
    <INPUT TYPE="button" VALUE="<=====" onClick="decreaseVolume()">
    <INPUT TYPE="button" VALUE="==^==" onClick="setDefaultVolume()">
    <INPUT TYPE="button" VALUE="=====>" onClick="increaseVolume()"><BR>
    </FORM>
    <P>The code is shown on the next page. The script is fairly straightforward. Let's take one function to demonstrate the principles of object referencing:</P>
    <P> <PRE><CODE><FONT COLOR="#0000cc">function playIt() {
      if (!audioEnabled) return;
      if (IEsound) </FONT><FONT COLOR="#cc0000">document.audiopanel.play()</FONT><FONT COLOR="#0000cc">
      else if (NSsound) </FONT><FONT COLOR="#009900">document.audiopanel.play(true)</FONT><FONT COLOR="#0000cc">;
      state();
      timerID = setTimeout("showPosition()", 1000);
    }</FONT></CODE></PRE> </P>
    <P>Explorer plays a sound track by the <CODE><FONT COLOR="#0000cc">play()</FONT></CODE> method, while Navigator does it with the <CODE><FONT COLOR="#0000cc">play()</FONT></CODE> one. Differences stem from the fact that Navigator uses the LiveAudio plug-in, while Explorer uses the ActiveMovie Control, as explained earlier in this column. On both browsers, an object is referenced as <CODE><FONT COLOR="#0000cc">document.audiopanel</FONT></CODE>, where <CODE><FONT COLOR="#0000cc">audiopanel</FONT></CODE> is the value of the <CODE><FONT COLOR="#0000cc">&lt;EMBED&gt;</FONT></CODE> tag's <CODE><FONT COLOR="#0000cc">NAME</FONT></CODE> attribute. The function <CODE><FONT COLOR="#0000cc">state()</FONT></CODE> prints the state of the sound control, and the last line of the <CODE><FONT COLOR="#0000cc">playIt()</FONT></CODE> function invokes the <CODE><FONT COLOR="#0000cc">setInterval()</FONT></CODE> function to update the position of the track every 1000 ms.</P>
    <P>Notice that the Explorer' ActiveMovie Control supports several features that Navigator does not. For example, Explorer lets you read the current playing position along the track, the audio file name, and if the sound card is enabled. Compare the feature table of LiveAudio with that of ActiveMovie Control, and you will find many more such features.</P>
    LiveScript: Putting the "Live" Back into JavaScript
    if live output_as_javascript else output_as_html end if


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •