Platforms to show: All Mac Windows Linux Cross-Platform
Required plugins for this example: MBS Audio Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /Audio/WindowsMCI/cdaudio
This example is the version from Sun, 17th Mar 2012.
Project "cdaudio.xojo_binary_project"
Class Window1 Inherits Window
Control PlayButton Inherits PushButton
ControlInstance PlayButton Inherits PushButton
EventHandler Sub Action()
// just play the music...
v.command="play cdaudio"
v.run
checkerror
End EventHandler
End Control
Control PauseButton Inherits PushButton
ControlInstance PauseButton Inherits PushButton
EventHandler Sub Action()
// send pause command
v.command="pause cdaudio"
v.run
checkerror
End EventHandler
End Control
Control ResumeButton Inherits PushButton
ControlInstance ResumeButton Inherits PushButton
EventHandler Sub Action()
// send resume command
v.command="resume cdaudio"
v.run
checkerror
End EventHandler
End Control
Control StopButton Inherits PushButton
ControlInstance StopButton Inherits PushButton
EventHandler Sub Action()
// send stop command
v.command="stop cdaudio"
v.run
checkerror
End EventHandler
End Control
Control EjectButton Inherits PushButton
ControlInstance EjectButton Inherits PushButton
EventHandler Sub Action()
// eject the disk by setting the door state to open
v.command="set cdaudio door open"
v.run
checkerror
End EventHandler
End Control
Control CloseButton2 Inherits PushButton
ControlInstance CloseButton2 Inherits PushButton
EventHandler Sub Action()
// close the door...
v.command="set cdaudio door closed"
v.run
checkerror
End EventHandler
End Control
Control lasterror Inherits Label
ControlInstance lasterror Inherits Label
End Control
Control UpdateTimer Inherits Timer
ControlInstance UpdateTimer Inherits Timer
EventHandler Sub Action()
update
End EventHandler
End Control
Control StaticText1 Inherits Label
ControlInstance StaticText1 Inherits Label
End Control
Control position Inherits Label
ControlInstance position Inherits Label
End Control
Control StaticText2 Inherits Label
ControlInstance StaticText2 Inherits Label
End Control
Control track Inherits Label
ControlInstance track Inherits Label
End Control
Control StaticText3 Inherits Label
ControlInstance StaticText3 Inherits Label
End Control
Control Trackcount Inherits Label
ControlInstance Trackcount Inherits Label
End Control
Control RandomButton Inherits PushButton
ControlInstance RandomButton Inherits PushButton
EventHandler Sub Action()
// get the number of tracks and play a random one
dim count as integer
v.command="Status cdaudio Number of Tracks"
v.run
count=val(v.result)
v.command="Play cdaudio From "+format(floor(1+rnd*count),"0")
v.run
checkerror
End EventHandler
End Control
Control PrevButton Inherits PushButton
ControlInstance PrevButton Inherits PushButton
EventHandler Sub Action()
// get the current one, subtract one and play it if it's in range
dim current as integer
dim counts as string
v.command="Status cdaudio Current Track"
v.run
current=val(v.result)
v.command="Status cdaudio Number of Tracks"
v.run
counts=v.result
if current>1 then
v.command="Play cdaudio From "+format(current-1,"0")+" to "+counts
v.run
end if
checkerror
End EventHandler
End Control
Control NextButton Inherits PushButton
ControlInstance NextButton Inherits PushButton
EventHandler Sub Action()
// get the current one, add one and play it if it's in range
dim current,count as integer
dim counts as string
v.command="Status cdaudio Current Track"
v.run
current=val(v.result)
v.command="Status cdaudio Number of Tracks"
v.run
counts=v.result
count=Val(counts)
if current<count then
v.command="Play cdaudio From "+format(current+1,"0")+" To "+counts
v.run
end if
checkerror
End EventHandler
End Control
EventHandler Sub Close()
// close the device and quit
v.command="close cdaudio"
v.run
quit
End EventHandler
EventHandler Sub Open()
// open the CD Device and set time format to Track:Minute:Second:Frame
v=new WindowsMCIMBS
v.Command="open cdaudio"
v.run
checkerror
v.Command="set cdaudio time format TMSF"
v.run
updatetimer.mode=2
End EventHandler
Sub checkerror()
// show the errorcode and the error message
lasterror.text=str(v.errorcode)+" "+v.errorstring
End Sub
Sub update()
// get the current position, track and track count to display.
v.Command="Status cdaudio Current Track"
v.run
track.text=v.result
v.command="Status cdaudio Number of Tracks"
v.run
if trackcount.text<>v.result then // redraw screen only if changed
trackcount.text=v.result
end if
v.command="Status cdaudio position"
v.run
if position.text<>v.result then // redraw screen only if changed
position.text=v.result
end if
End Sub
Property Protected v As windowsMCIMBS
End Class
MenuBar Menu
MenuItem UntitledMenu3 = ""
MenuItem UntitledMenu2 = "File"
MenuItem FileQuit = "Quit"
MenuItem UntitledMenu0 = "Edit"
MenuItem EditUndo = "Undo"
MenuItem UntitledMenu1 = "-"
MenuItem EditCut = "Cut"
MenuItem EditCopy = "Copy"
MenuItem EditPaste = "Paste"
MenuItem EditClear = "Clear"
End MenuBar
Class App Inherits Application
End Class
End Project
The items on this page are in the following plugins: MBS Audio Plugin.