mp3 Player``playing a midi file by yves turgeon
Posted: Sun Jun 24, 2007 1:46 am
source code:
``playing a midi file by marco waterman
``this api can do more things like opening the cd tray or
``playing avi files.
`and playing mp3 file by yves turgeon
Declare GetShortPathName as "GetShortPathNameA" of "kernel32" ` this is for playing long file name
lpszLongPath As String
lpszShortPath As String
lBuffer As Single
end declare
Declare sendstring as "mciSendStringA" of "winmm.dll"
lpstrCommand As String
lpstrReturnString As String
uReturnLength As integer
hwndCallback As integer
result as integer
end declare
object myform as form
height = 100
width=350
color=&hFFB871
caption="play a mp3 file"
object open1 as button
left=10
top=10
caption="Open"
onclick=open_click
end object
object play as button
left=120
top=10
caption="Play >>"
onclick=play_click
end object
object quit as button
left=210
top=10
caption="[ Stop ]"
onclick=quit_click
end object
end object
dim file as filedialog
myform.ShowModal
dim alias as string
sub open_click()
file.caption="select a mp3 file"
file.Filter = "Mp3 files (*.mp3)|*.mp3"
file.Show
myform.caption = file.FileName
alias=part$(file.filename,"",instr(file.filename,"."))
alias=field$(alias,".",1)
alias=left$(alias,2) `this is a way to do without using GetShortPathName
myform.Caption=file.FileName
end sub
sub play_click()
sendstring.lpstrcommand="OPEN "+chr$(34)+file.FileName+chr$(34)+" TYPE MpegVideo ALIAS "+alias
sendstring
sendstring.lpstrcommand="play "+alias+" from 0"
sendstring
end sub
sub quit_click()
sendstring.lpstrcommand="stop "+alias
sendstring
end sub
``playing a midi file by marco waterman
``this api can do more things like opening the cd tray or
``playing avi files.
`and playing mp3 file by yves turgeon
Declare GetShortPathName as "GetShortPathNameA" of "kernel32" ` this is for playing long file name
lpszLongPath As String
lpszShortPath As String
lBuffer As Single
end declare
Declare sendstring as "mciSendStringA" of "winmm.dll"
lpstrCommand As String
lpstrReturnString As String
uReturnLength As integer
hwndCallback As integer
result as integer
end declare
object myform as form
height = 100
width=350
color=&hFFB871
caption="play a mp3 file"
object open1 as button
left=10
top=10
caption="Open"
onclick=open_click
end object
object play as button
left=120
top=10
caption="Play >>"
onclick=play_click
end object
object quit as button
left=210
top=10
caption="[ Stop ]"
onclick=quit_click
end object
end object
dim file as filedialog
myform.ShowModal
dim alias as string
sub open_click()
file.caption="select a mp3 file"
file.Filter = "Mp3 files (*.mp3)|*.mp3"
file.Show
myform.caption = file.FileName
alias=part$(file.filename,"",instr(file.filename,"."))
alias=field$(alias,".",1)
alias=left$(alias,2) `this is a way to do without using GetShortPathName
myform.Caption=file.FileName
end sub
sub play_click()
sendstring.lpstrcommand="OPEN "+chr$(34)+file.FileName+chr$(34)+" TYPE MpegVideo ALIAS "+alias
sendstring
sendstring.lpstrcommand="play "+alias+" from 0"
sendstring
end sub
sub quit_click()
sendstring.lpstrcommand="stop "+alias
sendstring
end sub