LB Booster
General >> General Board >> New to lbb & coding - Mp3 shuffle player
http://lbb.conforums.com/index.cgi?board=general&action=display&num=1442525669

New to lbb & coding - Mp3 shuffle player
Post by mattlp1980 on Sep 17th, 2015, 9:34pm

Hi all new to lbb & coding so need to start at beginning wink

Looking to create an Mp3 shuffle player (shuffle default) to shuffle 1000+ 1 - 2 second audio files from set directory with option of play speed via a slider.

Set a created Jpeg as player background.

Just looking for best read or e-books to learn required coding.

Thanks in advance
Re: New to lbb & coding - Mp3 shuffle player
Post by Richard Russell on Sep 17th, 2015, 10:44pm

on Sep 17th, 2015, 9:34pm, mattlp1980 wrote:
Looking to create an Mp3 shuffle player

Here's a very simple MP3 player. Hopefully you can achieve most of what you want by means of other MCI commands, there's a list at MSDN.

Code:
    filedialog "Select an MP3 file", "*.mp3", mp3file$
    if mp3file$ = "" then end
    
    ret$ = mciSendString$("open " + chr$(34) + mp3file$ + chr$(34) + _
                          " type mpegvideo alias music")
    ret$ = mciSendString$("play music")
    if ret$ = "" then print "Playing "; mp3file$
    end

function mciSendString$(s$)
    buffer$ = space$(1024)+chr$(0)
    buflen = len(buffer$)
    calldll #winmm, "mciSendStringA", s$ as ptr, buffer$ as ptr,_
      buflen as long, 0 as long, ret as short
    if ret then
        mciSendString$ = "error ";ret
    else
        mciSendString$ = trim$(buffer$)
    end if
end function 

Richard.
Re: New to lbb & coding - Mp3 shuffle player
Post by mattlp1980 on Sep 17th, 2015, 11:07pm

Thank you Richard that's a great start.

Would I add files names in same line to play multiple audio files what would separate each mp3 file name? \ | : ,

or can I set a directory as default to play via a button without allowing users to choose a file?

Matt




Re: New to lbb & coding - Mp3 shuffle player
Post by Richard Russell on Sep 18th, 2015, 02:01am

on Sep 17th, 2015, 11:07pm, mattlp1980 wrote:
or can I set a directory as default to play via a button without allowing users to choose a file?

The Liberty BASIC FILES statement will fill an array with all the MP3 files in a specified directory:

https://lbpe.wikispaces.com/UsingTheFilesStatement

Richard.