$INCLUDE "RapidQ.inc"
DECLARE SUB stopclick
DECLARE SUB playclick
DECLARE SUB formclose
DECLARE FUNCTION mcisendstring LIB "winmm.dll" ALIAS "mciSendStringA" _
(BYVAL lpstrCommand AS STRING, lpstrReturnString AS LONG, uReturnLength AS _
LONG, hwndCallback AS LONG) AS LONG
DECLARE FUNCTION GetShortPathName LIB "kernel32" ALIAS "GetShortPathNameA" _
(BYVAL lpszLongPath AS STRING, BYVAL lpszShortPath AS LONG, BYVAL lBuffer AS LONG) AS LONG
DEFBYTE x,s
DIM audio AS STRING*256
DIM title AS STRING,track AS STRING
CREATE Form1 AS QFORM
BorderStyle=bsSingle
CAPTION="MP3 player"
COLOR=&H8000
Left=370
Top=207
Width=256
delbordericons(bimaximize)
CREATE fileListbox1 AS QFILELISTBOX
Left=6
TabOrder=1
Top=6
Width=236
mask="*.mp3"
multiselect=1
directory="c:\playlist"
END CREATE
CREATE Coolbtn1 AS QCOOLBTN
CAPTION="Play"
GroupIndex=1
Left=6
Top=144
Width=100
onclick=playclick
END CREATE
CREATE Coolbtn2 AS QCOOLBTN
CAPTION="Stop"
GroupIndex=1
Left=142
Top=144
Width=100
onclick=stopclick
END CREATE
CREATE label AS QLABEL
CAPTION=""
left=6
top=194
width=234
END CREATE
END CREATE
Form1.SHOWMODAL
SUB playclick
coolbtn1.enabled=0
x=0:s=0
DO
IF filelistbox1.selected(x)=1 THEN
title=filelistbox1.item(x)
filepath$=STRING$(164,0)
lentitle=getshortpathname(title,VARPTR(filepath$),164)
track=LEFT$(filepath$,lentitle)
GOTO proceed
END IF
GOTO examine
proceed:
DOEVENTS
label.CAPTION="c:\playlist\"+title
mcisendstring("play "+track,0,0,0)
DO
DOEVENTS
mcisendstring("status "+track+" mode",VARPTR(audio),256,0)
LOOP UNTIL LEFT$(audio,4)="stop" OR s=1
mcisendstring("close "+track,0,0,0)
examine:
INC x
label.CAPTION=""
LOOP UNTIL x>filelistbox1.itemcount-1
END SUB
SUB stopclick
coolbtn1.enabled=1
s=1
mcisendstring("stop "+track,0,0,0)
label.CAPTION=""
END SUB
SUB formclose
mcisendstring("close all",0,0,0)
form1.CLOSE
END SUB
|