dcsimg
www.webdeveloper.com
Results 1 to 6 of 6

Thread: AllowShuffle param for playlists

  1. #1
    Join Date
    Jan 2005
    Posts
    27

    AllowShuffle param for playlists

    I am not sure why the AllowShuffle is not actually playing the songs in a random fashion in my playlist below. Has anyone experienced this and know what the correct way to code this up is? When I start the below playlist in windows media player, the songs are played sequentially, then repeated. I need for them to play randomly then when all songs are done repeat the same process of randomized play. Thanks in advance.

    <ASX version ="3.0">
    <Param Name = "AllowShuffle" Value = "yes" />
    <REPEAT>
    <Entry>
    <DURATION VALUE="00:00:30" />
    <Ref href="song1.mp3"/>
    <StartTime value="00:00:60" />
    </Entry>
    <Entry>
    <DURATION VALUE="00:00:30" />
    <Ref href="song2.mp3"/>
    </Entry>
    <Entry>
    <DURATION VALUE="00:00:30" />
    <Ref href="song3.mp3"/>
    </Entry>
    <Entry>
    <DURATION VALUE="00:00:30" />
    <Ref href="song4.mp3"/>
    </Entry>
    </REPEAT>
    </ASX>

  2. #2
    Join Date
    Jan 2005
    Posts
    27
    I've done some testing and found that the AllowShuffle does not actually randomize the playlist, but rather overrides the users ability to shuffle a playlist. If Value is "no" then all the songs in the users playlist will play sequencially regardless of whether the shuffle option on the player is checked. Whereas if the value is Yes then the user can actually have sounds played in a random fashion. I still have not found an option that will shuffle my playlist anyone know of that option? I have a script that will select random songs but it conflicts with another script I have because both use the onload command. So I'm looking for a built in param. Thanks.

  3. #3
    Join Date
    Jun 2004
    Location
    Kansas City, MO
    Posts
    1,607
    Im not sure about that, but is there any way you could do a random number, and create you own kind or auto shuffle. Lets say you have the 5 links below.

    When you open the page call a function that will display those links in a random order. They will (assuming i read your last posts correclty) will play from top to bottom but they will always dispaly differenly every time the page is refreshed.

    How about something like that.

  4. #4
    Join Date
    Jan 2005
    Posts
    27
    I got the below script from user Warren86 and it works fine. I modified it to play playlists instead of single songs. By using a playlist I am able to play numerous multiple songs as opposed to playing one random song. The issue with using this script is that I have another script that displays a slide show both using the onload command. So in this case the last script that I source in my html will win. i.e.

    <script type="text/javascript" src=script1.js></script>
    <script type="text/javascript" src=script2.js></script>

    Therefore script2 will function and script1 will not. To get around this I said I would leave the slide show and look for a built in option for the playlist to randomly play songs from a playlist. What I said before about the AllowShuffle is correct, try it out when you get a chance. Create a playlist similar to what I have and run the playlist both with the shuffle option on and off from windows media player.

    <HTML>
    <Head>
    <Script Language=JavaScript>

    audioClip = new Object
    audioClip.A = "http://french.about.com/library/media/wavs/zero.wav"
    audioClip.B = "http://french.about.com/library/media/wavs/1.wav"
    audioClip.C = "http://french.about.com/library/media/wavs/2.wav"
    audioClip.D = "http://french.about.com/library/media/wavs/3.wav"

    var nClips = new Array();
    n = 0;

    for (each in audioClip){nClips[n++] = audioClip[each]}

    isMax = nClips.length-1;

    function getClip(){

    isIndex = 0+Math.round(Math.random()*isMax);
    currClip = nClips[isIndex];
    playIt(currClip);
    }

    function playIt(URL){

    isSelection = URL;
    embedStr = "<Embed Src="+isSelection+" Width=0 Height=0></Embed>"
    document.getElementById('isEmbed').innerHTML = embedStr;
    }

    window.onload=getClip;

    </Script>
    </Head>
    <Body>
    <center>
    <Div id='isEmbed'></Div><br>
    </center>
    </Body>
    </HTML>

  5. #5
    Join Date
    Apr 2013
    Posts
    2

    Alternative to random integer

    1. Check your ASX file is working, this can be done using your existing code or opening it in Windows Media Player.
    Make sure that your ASX contains this line <param name="AllowShuffle" value="Yes">

    2. Change your <object> tag to this:
    <input id="shuffle" style="display:none;" onClick="shufflePlayer()">
    <script>
    <!--
    function shufflePlayer()
    {
    MPlayer.Settings.setMode("shuffle", 1);
    MPlayer.url= file.asx /* replace with the name of file */
    MPlayer.controls.play();
    }

    -->
    </script>
    <object id="MPlayer"
    classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6">
    <param name="Showcontrols" value="True">

    <param name="autoStart" value="True"> <!-- Recommended, not required though -->
    <param name="AllowShuffle" value="Yes"> <!-- Required -->
    <param name="Volume" value="100">
    <param name="EnableContextMenu" value="False"><!-- to stop people trying to change things -->

    3. Then add this line of code to the onload function i.e.
    document.getElementById("shufflebtn").click()

    (This is to avoid conflict with any other onload scripts taking place)
    4. If it is not working, with MP3 files.
    You can switch to WPL format, which is simpler too (don't if you are using ASF files though):

    example:
    <?wpl version="1.0"?>
    <smil>
    <head>
    <meta name="Generator" content="Microsoft Windows Media Player -- 12.0.9200.16384"/>
    <meta name="IsNetworkFeed" content="0"/>
    <title>Playlist</title>
    </head>

    <body>
    <seq>
    <media src="file1.mp3"/>
    <media src="file2.mp3"/>
    </seq>
    </body>
    </smil>

  6. #6
    Join Date
    Apr 2013
    Posts
    2
    What you need for your situation is:
    Option A :
    Keep Reading
    OPTION B:
    Create a hidden input button:
    <input id="randomiserbtn" onClick="name of script here" style="display:none" type="button">

    Add this line to the end or where appropriate to the loading script
    document.getElementById("randomiserbtn").click()

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles