Platforms to show: All Mac Windows Linux Cross-Platform
Required plugins for this example: MBS AVFoundation Plugin, MBS Main Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /AVFoundation/AVMidiPlayer
This example is the version from Mon, 10th Jul 2016.
Project "AVMidiPlayer.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Delete"
Const kFileQuit = "&Quit"
Const kFileQuitShortcut = ""
End Class
Class MainWindow Inherits Window
Control OpenButton Inherits PushButton
ControlInstance OpenButton Inherits PushButton
EventHandler Sub Action()
dim f as FolderItem = GetOpenFolderItem(FileTypes1.AudioMidi)
if f = nil then Return
dim e as NSErrorMBS
Dim m as new AVMIDIPlayerMBS(f, nil, e)
a = m
CloseMidiButton.Enabled = true
playbutton.enabled = true
StopButton.Enabled = true
PositionSlider.Enabled = true
End EventHandler
End Control
Control playButton Inherits PushButton
ControlInstance playButton Inherits PushButton
EventHandler Sub Action()
a.play
End EventHandler
End Control
Control StopButton Inherits PushButton
ControlInstance StopButton Inherits PushButton
EventHandler Sub Action()
a.Stop
End EventHandler
End Control
Control Info Inherits Label
ControlInstance Info Inherits Label
End Control
Control PositionSlider Inherits Slider
ControlInstance PositionSlider Inherits Slider
EventHandler Sub ValueChanged()
if NoEvents then Return
a.CurrentPosition = a.Duration * me.Value / 1000.0
End EventHandler
End Control
Control Timer1 Inherits Timer
ControlInstance Timer1 Inherits Timer
EventHandler Sub Action()
dim s as string
if a <> nil then
s = str(a.CurrentPosition, "0.0") + " / " + str(a.Duration, "0.0")
dim p as integer = 1000 * a.CurrentPosition / a.Duration
NoEvents = true
PositionSlider.value = p
NoEvents = false
end if
if s <> info.Text then
info.Text = s
end if
End EventHandler
End Control
Control CloseMidiButton Inherits PushButton
ControlInstance CloseMidiButton Inherits PushButton
EventHandler Sub Action()
CloseMidiButton.Enabled = false
PositionSlider.Enabled = false
info.Text = ""
StopButton.Enabled = False
playButton.Enabled = False
a = nil
End EventHandler
End Control
Property NoEvents As Boolean
Property a As AVMIDIPlayerMBS
End Class
MenuBar MenuBar1
MenuItem FileMenu = "&File"
MenuItem FileQuit = "#App.kFileQuit"
MenuItem EditMenu = "&Edit"
MenuItem EditUndo = "&Undo"
MenuItem UntitledMenu1 = "-"
MenuItem EditCut = "Cu&t"
MenuItem EditCopy = "&Copy"
MenuItem EditPaste = "&Paste"
MenuItem EditClear = "#App.kEditClear"
MenuItem UntitledMenu0 = "-"
MenuItem EditSelectAll = "Select &All"
End MenuBar
FileTypes1
Filetype audio/midi
End FileTypes1
End Project
The items on this page are in the following plugins: MBS AVFoundation Plugin.