Platforms to show: All Mac Windows Linux Cross-Platform

/Audio/Windows Player


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/Windows Player

This example is the version from Thu, 8th Jan 2020.

Project "Windows Player.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Löschen"
Const kFileQuit = "Beenden"
Const kFileQuitShortcut = ""
End Class
Class MainWindow Inherits Window
Control PlayButton Inherits PushButton
ControlInstance PlayButton Inherits PushButton
EventHandler Sub Action() If OutputMenu.ListIndex >= 0 Then Dim d As WindowsPlayerDeviceMBS = OutputMenu.RowTag(OutputMenu.ListIndex) If d = Nil Then player.DeviceID = -1 // default Else player.DeviceID = d.Index If d.Channels > 0 Then // has individual channels If ChannelMenu.ListIndex >= 0 Then Dim mask As Integer = ChannelMenu.RowTag(ChannelMenu.ListIndex) player.ChannelMask = mask End If End If End If End If player.play End EventHandler
End Control
Control PauseButton Inherits PushButton
ControlInstance PauseButton Inherits PushButton
EventHandler Sub Action() player.Pause End EventHandler
End Control
Control Label3 Inherits Label
ControlInstance Label3 Inherits Label
End Control
Control ResumeButton Inherits PushButton
ControlInstance ResumeButton Inherits PushButton
EventHandler Sub Action() player.Resume End EventHandler
End Control
Control SliderVolumeT Inherits Slider
ControlInstance SliderVolumeT Inherits Slider
EventHandler Sub ValueChanged() if noEvents then Return noEvents = true player.Volume = me.Value / 100.0 noEvents = false QueryVolume End EventHandler
End Control
Control Label1 Inherits Label
ControlInstance Label1 Inherits Label
End Control
Control Label2 Inherits Label
ControlInstance Label2 Inherits Label
End Control
Control SliderVolumeL Inherits Slider
ControlInstance SliderVolumeL Inherits Slider
EventHandler Sub ValueChanged() if noEvents then Return noEvents = true dim r,l as Double player.GetVolume(l, r) l = me.Value / 100.0 player.SetVolume(l, r) noEvents = false QueryVolume End EventHandler
End Control
Control SliderVolumeR Inherits Slider
ControlInstance SliderVolumeR Inherits Slider
EventHandler Sub ValueChanged() if noEvents then Return noEvents = true dim r,l as Double player.GetVolume(l, r) r = me.Value / 100.0 player.SetVolume(l, r) noEvents = false QueryVolume End EventHandler
End Control
Control Label4 Inherits Label
ControlInstance Label4 Inherits Label
End Control
Control SliderRate Inherits Slider
ControlInstance SliderRate Inherits Slider
EventHandler Sub ValueChanged() if noEvents then Return noEvents = true player.rate = me.Value / 100.0 noEvents = false End EventHandler
End Control
Control SliderPosition Inherits Slider
ControlInstance SliderPosition Inherits Slider
EventHandler Sub ValueChanged() if noEvents then Return noEvents = true player.Volume = me.Value / 100.0 noEvents = false QueryVolume End EventHandler
End Control
Control SliderPitch Inherits Slider
ControlInstance SliderPitch Inherits Slider
EventHandler Sub ValueChanged() if noEvents then Return noEvents = true player.pitch = me.Value / 100.0 noEvents = false End EventHandler
End Control
Control Label5 Inherits Label
ControlInstance Label5 Inherits Label
End Control
Control OutputMenu Inherits PopupMenu
ControlInstance OutputMenu Inherits PopupMenu
EventHandler Sub Change() If Me.ListIndex >= 0 Then Dim d As WindowsPlayerDeviceMBS = Me.RowTag(Me.ListIndex) If d = Nil Then ChannelMenu.DeleteAllRows else dim m as integer = 1 // mask Dim n As Integer = ChannelMenu.ListIndex ChannelMenu.DeleteAllRows Dim u As Integer = d.Channels-1 System.DebugLog "d.Channels: "+str(d.Channels) For i As Integer = 0 To u ChannelMenu.AddRow Str(i+1)+"th channel" ChannelMenu.RowTag(i) = m m = m * 2 If i = n Then // restore selection ChannelMenu.ListIndex = n End If Next End If End If End EventHandler
End Control
Control ChannelMenu Inherits PopupMenu
ControlInstance ChannelMenu Inherits PopupMenu
End Control
EventHandler Sub Open() // fill devices into a popupmenu Dim c As Integer = WindowsPlayerMBS.DeviceCount OutputMenu.AddRow "Default" For i As Integer = 0 To c-1 Dim d As WindowsPlayerDeviceMBS = WindowsPlayerMBS.Device(i) OutputMenu.AddRow d.Name+" "+Str(d.Channels) OutputMenu.RowTag(OutputMenu.ListCount-1) = d Next Dim file As FolderItem = SpecialFolder.Desktop.Child("test.mp3") player = New WindowsPlayerMBS(file) QueryVolume noEvents = True SliderRate.value = player.Rate * 100 SliderPitch.value = player.Pitch * 100 noEvents = False End EventHandler
Sub QueryVolume() noEvents = True SliderVolumeT.value = player.Volume * 100 dim r,l as Double player.GetVolume(l, r) SliderVolumeL.value = l * 100 SliderVolumeR.value = r * 100 noEvents = False End Sub
Property noEvents As Boolean
Property player As WindowsPlayerMBS
End Class
MenuBar MenuBar1
MenuItem FileMenu = "&Ablage"
MenuItem FileQuit = "#App.kFileQuit"
MenuItem EditMenu = "&Bearbeiten"
MenuItem EditUndo = "&Rückgängig"
MenuItem UntitledMenu1 = "-"
MenuItem EditCut = "&Ausschneiden"
MenuItem EditCopy = "&Kopieren"
MenuItem EditPaste = "&Einfügen"
MenuItem EditClear = "#App.kEditClear"
MenuItem UntitledMenu0 = "-"
MenuItem EditSelectAll = "&Alles auswählen"
End MenuBar
End Project

See also:

The items on this page are in the following plugins: MBS Audio Plugin.


The biggest plugin in space...