Liberty BASIC Community Forum
« How to play sequentially a mp3 list »

Welcome Guest. Please Login or Register.
Dec 12th, 2017, 08:07am


Rules|Home|Help|Search|Recent Posts|Notification


« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: How to play sequentially a mp3 list  (Read 155 times)
fox
Full Member
ImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 176
xx How to play sequentially a mp3 list
« Thread started on: Jan 27th, 2017, 11:04am »

Hi all.
I understood ( with a lot of difficulty) how to play, with dll #winmm, a single mp3 for once, but I'm not able to understand how to play a list of 10 (or more) mp3 sequentially and automatically.
Please, can anybody help me to understand?
Thanks a lot and bye
fox
« Last Edit: Jan 27th, 2017, 11:10am by fox » User IP Logged

Roger Thomas
Junior Member
ImageImage


member is offline

Avatar




Homepage PM


Posts: 71
xx Re: How to play sequentially a mp3 list
« Reply #1 on: Jan 28th, 2017, 12:07am »

Code:
dim playlistPath$(20)
'files to play. add more of these up to 20
playlistPath$(1) = "C:\file1.mp3"
playlistPath$(2) = "C:\file2.mp3"
playlistPath$(3) = "C:\file3.mp3"

playlistPosition = 1

[Play]'code to play file.
m$ = GetShortPathName$(playlistPath$(playlistPosition))
print m$
r$=mciSendString$("open "+m$+" type MpegVideo alias music")
r$=mciSendString$("play music")
r$=mciSendString$("status music length")
mediaLength = val(r$)
if m$ <> "" then
   timer 100, [CheckPosition]
 else
   timer, 0
end if
wait

[CheckPosition]
r$=mciSendString$("status music position")
currentPosition = val(r$)
if currentPosition >= mediaLength then
   r$=mciSendString$("close music")
   playlistPosition = playlistPosition +1
if playlistPosition > 3 then playlistPosition = 1 'change the 3 to how many files you have.
goto [Play]
end if
wait

Function mciSendString$(s$) 'Sends multimedia commands
Open "winmm.dll" for dll as #winmm
    buffer$=space$(1024)+chr$(0)
    calldll #winmm,"mciSendStringA",s$ as ptr,buffer$ as ptr,_
        1028 as long, 0 as long, r as long
    buffer$=left$(buffer$, instr(buffer$, chr$(0)) - 1)
        if r = 0 then
           mciSendString$=buffer$
        else
           print "mciSendString error ";r
        end if
close #winmm
End Function

Function GetShortPathName$(lPath$) 'Returns short version of pathname
    lPath$=lPath$+chr$(0)
    sPath$=space$(256)
    lenPath=len(sPath$)
    calldll #kernel32, "GetShortPathNameA",lPath$ as ptr,_
    sPath$ as ptr,lenPath as long,r as long
    GetShortPathName$=left$(sPath$,r)
end function
 


Hope this helps.
« Last Edit: Jan 28th, 2017, 11:32am by Roger Thomas » User IP Logged

fox
Full Member
ImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 176
xx Re: How to play sequentially a mp3 list
« Reply #2 on: Jan 28th, 2017, 03:48am »

Thanks a lot again, Roger.
You solved my second problem about mp3.
Please, another suggestion: personally I have a lot of difficulty to understand something about Api for LB..... you, how have learned all you know about this argument? (textbooks, forum, school....).
Thanks a lot again and bye
fox
User IP Logged

Roger Thomas
Junior Member
ImageImage


member is offline

Avatar




Homepage PM


Posts: 71
xx Re: How to play sequentially a mp3 list
« Reply #3 on: Jan 28th, 2017, 10:06am »

I just studied everything I could find on here and the links at the top of the site. Went to the msdn site and googled a lot.

You have to keep studying it trying. About the time you start to give up on what you are trying to do, You'll get it, and think: "Why didn't I see that a long time ago?" Or at least, that happens to me a lot.

Took a while. Still not a code pro like some on here. sad

Roger
User IP Logged

fox
Full Member
ImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 176
xx Re: How to play sequentially a mp3 list
« Reply #4 on: Jan 28th, 2017, 12:58pm »

Ok, Roger.
I think your suggestion is correct.
Studying and at the same time trying is the right way to understand something.
Thanks a lot again and bye
fox
User IP Logged

Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

Rules|Home|Help|Search|Recent Posts|Notification

Donate $6.99 for 50,000 Ad-Free Pageviews!

| |

This forum powered for FREE by Conforums ©
Sign up for your own Free Message Board today!
Terms of Service | Privacy Policy | Conforums Support | Parental Controls