Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Feb 2007
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Using a javascript mp3 player, is it possible to get the script to play random files?

    Using a javascript mp3 player, is it possible to get the script to play random mp3 files out of a designated foler? For example, if I have a folder named "music" and I want the script to open up the folder and select a random file for playback, is this even possible? Is there some code I can add to the script that will make this work? This si the code for the entire webpage...

    -----------------------------------------------------------
    <head>
    <title>radio</title>

    <link rel="stylesheet" type="text/css" href="lb_JSPlayer.css" />

    <script type="text/javascript" src="cookies.js"></script>
    <script type="text/javascript" src="lb_common.js"></script>
    <script type="text/javascript" src="lb_html.js"></script>

    <script type="text/javascript" src="lb_menu.js"></script>
    <script type="text/javascript" src="lb_JSPlayer_core.js"></script>
    <script type="text/javascript" src="lb_JSPlayer.js"></script>
    </head>
    <body>

    <script language="Javascript">
    new clb_JSPlayer("***filelink****", "QTP", "****filelink****");
    </script>

    </body>

    -----------------------------------------------------------

    The page can be viewed at http://www.twwn.net/radio/radio.php

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,988
    Thanks
    203
    Thanked 2,536 Times in 2,514 Posts
    Try this:-

    Code:
    <SCRIPT type= "text/javascript">
    // var numsongs stands for the number of songs given
    var numsongs = 5 // replace with any number you want
    day = new Date()
    seed = day.getTime()
    ran = parseInt(((seed - (parseInt(seed/1000,10) * 1000))/10)/100*numsongs
    + 1,10)
     
    if (ran == (5))
    {
    song =("insert file src here")
    words =("input song title here")
    }
    else if (ran == (4))
    {
    song =("insert file src here")
    words =("input song title here")
    }
    else if (ran == (3))
    {
    song =("insert file src here")
    words =("input song title here")
    }
    else if (ran == (2))
    {
    song =("insert file src here")
    words =("input song title here")
    }
    else if (ran == (1))
    {
    song =("insert file src here")
    words =("input song title here")
    }
    
    document.write('<EMBED SRC= "' + song + '" CONTROLS=smallconsole HEIGHT=45 WIDTH=290 AUTOSTART=TRUE LOOP=TRUE VOLUME=35%>')
    document.write('<br>You are listening to ' + words + ' ')
    </SCRIPT>

  • #3
    New Coder
    Join Date
    Jan 2007
    Posts
    93
    Thanks
    0
    Thanked 0 Times in 0 Posts
    But you want to just point to a folder and have it open it and
    read all mp3 files in there by itself and random play one.

    could be done, but
    var fso=new ActiveXObject("Scripting.FileSystemObject");

    Creates warnings, unless run localaly and renamed .hta


  •  

    Posting Permissions

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