$OPTION ICON "midi.ico"
$TYPECHECK ON
$INCLUDE "Rapidq.inc"
$INCLUDE "QMidi.inc"
$RESOURCE PLAYBMP AS "play.bmp"
$RESOURCE PLAYRBMP AS "playr.bmp"
$RESOURCE PLAYLBMP AS "playl.bmp"
$RESOURCE STOPBMP AS "Stop.bmp"
$RESOURCE PAUSEBMP AS "Pause.bmp"
DECLARE SUB Play
DECLARE SUB Playr
DECLARE SUB Playl
DECLARE SUB Stop
DECLARE SUB Pause
DECLARE SUB OPEN
DECLARE SUB CLOSE
DECLARE SUB Quitter
DECLARE SUB TrackBarChange
DECLARE SUB PostimerOnTimer(Position AS LONG)
DIM OpenDialog AS QOPENDIALOG
OpenDialog.Filter= "Midi files (*.mid;*.kar)|*.mid;*.kar"
OpenDialog.CAPTION= "Selectionner une séquence"
DIM midi AS QMidi
midi.OnChange=PostimerOnTimer
midi.TIMER.interval=200
DIM B AS BYTE
CREATE Form AS QFORM
CAPTION="Midi"
Width=288
Height=100
Center
BorderStyle=bsSingle
DelBorderIcons 2
OnClose=Quitter
CREATE MENU AS QMAINMENU
CREATE FileMenu AS QMENUITEM
CAPTION="&File"
CREATE Item1 AS QMENUITEM
CAPTION="&Open"
OnClick=OPEN
END CREATE
CREATE Item2 AS QMENUITEM
CAPTION="&Close"
OnClick=CLOSE
END CREATE
CREATE Item3 AS QMENUITEM
CAPTION="-"
END CREATE
CREATE Item4 AS QMENUITEM
CAPTION="&Exit"
OnClick=Quitter
END CREATE
END CREATE
END CREATE
CREATE Panel1 AS QPANEL
Left=0
Top=0
Width=281
Height=45
BevelOuter=bvNone
CREATE BtPlay AS QCOOLBTN
BMPHandle=PLAYBMP
Left=8
Top=6
Width=28
Height=28
Flat=true
Hint="Play"
ShowHint=true
GroupIndex=1
Enabled=false
OnClick=Play
END CREATE
CREATE BtStop AS QCOOLBTN
BMPHandle=STOPBMP
Left=46
Top=6
Width=28
Height=28
Down=true
Flat=true
Enabled=false
Hint="Stop"
ShowHint=true
GroupIndex=1
OnClick=Stop
END CREATE
CREATE BtPause AS QCOOLBTN
BMPHandle=PAUSEBMP
Left=84
Top=6
Width=28
Height=28
Flat=true
GroupIndex=1
Enabled=false
Hint="Pause"
ShowHint=true
OnClick=Pause
END CREATE
CREATE BtPlayr AS QCOOLBTN
BMPHandle=PLAYRBMP
Left=122
Top=6
Width=28
Height=28
Flat=true
GroupIndex=1
Enabled=true
Hint="Play-Repeat"
ShowHint=true
OnClick=Playr
END CREATE
CREATE BtPlayl AS QCOOLBTN
BMPHandle=PLAYLBMP
Left=160
Top=6
Width=28
Height=28
Flat=true
GroupIndex=1
Enabled=true
Hint="Play-Playlist"
ShowHint=true
OnClick=Playl
END CREATE
CREATE TrackBar1 AS QTRACKBAR
TickMarks=tmBoth
TickStyle=tsNone
Left=2
Top=40
LineSize=0
Width=272
Height=21
Hint="Position"
ShowHint=true
Enabled=true
OnChange=TrackBarChange
END CREATE
END CREATE
END CREATE
Form.SHOWMODAL
SUB OPEN
IF OpenDialog.EXECUTE THEN
midi.CLOSE
IF midi.OPEN(OpenDialog.FileName) THEN
TrackBar1.Max=midi.lenght
TrackBar1.Position=0
btPlay.Enabled=true
btStop.Enabled=true
btPause.Enabled=true
trackbar1.Enabled=true
ELSE
SHOWMESSAGE midi.ERROR
END IF
END IF
END SUB
SUB CLOSE
midi.CLOSE
btPlay.Enabled=false
btStop.Enabled=false
btPause.Enabled=false
trackbar1.Enabled=false
END SUB
SUB Play
B = 0
IF midi.FileOpen=false THEN BtStop.Down=True
midi.play
END SUB
SUB Playr
B = 1
IF midi.FileOpen=false THEN BtStop.Down=True
midi.play
END SUB
SUB Playl
B = 1
IF midi.FileOpen=false THEN BtStop.Down=True
midi.play
END SUB
SUB Stop
midi.stop
TrackBar1.Position=0
END SUB
SUB Pause
IF midi.FileOpen=false THEN BtStop.Down=True
midi.pause
END SUB
SUB TrackBarChange
midi.currentFrame=TrackBar1.Position
END SUB
SUB PostimerOnTimer(Position AS LONG)
TrackBar1.Position=Position
IF midi.state=MD_STOP THEN
midi.stop
TrackBar1.Position=0
BtStop.Down=True
IF B = 1 THEN
Playr
END IF
IF B = 2 THEN
Playr
END IF
END IF
END SUB
SUB Quitter
midi.CLOSE
form.CLOSE
END SUB
|