0

Using HD600 to play MP3s randomly



Is there any command that can be used to play a list of MP3's in a random order? We are going to use it for playing music only and would like to have it in a random order when playing. Is this possible?

1 comment

  • 0
    Avatar
    RokuLyndon


    Hi,



    There isn't a command or keyword to randomize a playlist or interactive playlist. But, a custom script would do this. If all you want to do is play every mp3 on the flash card randomly, try the following:



    'Looping audio randomly



    debug = true

    audio = CreateObject("roAudioPlayer")

    p = CreateObject("roMessagePort")

    audio.SetPort(p)

    RANDOM 'reseeds random number generator each time script is run



    DIM audiolist$(100) 'array holds 100 entries

    file_count=0

    current_track=0

    MEDEN=8 'value returned when end of audio track is reached.



    audio.SetAudioOutput(0)

    audio.SetVolume(100)



    REM Read all files from root directory

    if debug print "Reading contents of root directory."

    l=ListDir("\") 'reads the contents of the root into a list.





    ' Storing only mp3s found

    if debug print "Storing mp3s found in audiolist."



    for i=1 to l.Count()

    filename = l.RemoveHead()

    if right(filename,4) = ".mp3" then

    audiolist$(file_count)=filename

    file_count=file_count+1

    if debug print filename; " added."

    endif

    next



    if debug print file_count; " files found."





    audio_loop:

    current_track=rnd(file_count) 'generates random number from 1 to total # of files

    ok=audio.PlayFile(audiolist$(current_track-1))

    if ok=0 print "Error, problem playing file: "; audiolist$(current_track-1)





    wait_for_end:

    msg = wait(0, p)

    if type(msg) <> "roAudioEvent" then wait_for_end

    if msg.GetInt() <> MEDEN then wait_for_end



    goto audio_loop
Please sign in to leave a comment.