Platforms to show: All Mac Windows Linux Cross-Platform

/AVFoundation/Device List


Required plugins for this example: MBS Util Plugin, MBS AVFoundation Plugin, MBS MacCG Plugin, MBS MacCF Plugin, MBS Main Plugin, MBS MacBase Plugin

You find this example project in your Plugins Download as a Xojo project file within the examples folder: /AVFoundation/Device List

This example is the version from Thu, 25th Dec 2019.

Project "Device List.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Löschen"
Const kFileQuit = "Beenden"
Const kFileQuitShortcut = ""
EventHandler Sub Open() if AVAssetExportSessionMBS.available = false then MsgBox "Please run on Mac OS X 10.7 or newer." quit end if AVFoundation = new AVFoundationMBS End EventHandler
Property AVFoundation As AVFoundationMBS
End Class
Class Window1 Inherits Window
Control List Inherits Listbox
ControlInstance List Inherits Listbox
EventHandler Sub ExpandRow(row As Integer) dim v as Variant = me.RowTag(row) if v = nil then Return if v.IsArray then // special handling for arrays dim u as integer = GetVariantArrayUboundMBS(v) if u>=0 then dim e as Variant = GetVariantArrayValueMBS(v,0) if e isa AVCaptureDeviceInputMBS then dim a() as AVCaptureDeviceInputMBS = v for each x as AVCaptureDeviceInputMBS in a addCaptureDeviceInput x next elseif e isa AVCaptureDeviceMBS then dim a() as AVCaptureDeviceMBS = v For Each x As AVCaptureDeviceMBS In a addCaptureDevice x, "Device" next elseif e isa AVCaptureDeviceInputSourceMBS then dim a() as AVCaptureDeviceInputSourceMBS = v for each x as AVCaptureDeviceInputSourceMBS in a AddCaptureDeviceInputSource x next elseif e isa AVCaptureDeviceFormatMBS then dim a() as AVCaptureDeviceFormatMBS = v for each x as AVCaptureDeviceFormatMBS in a AddCaptureDeviceFormat x next elseif e isa AVCaptureInputPortMBS then dim a() as AVCaptureInputPortMBS = v for each x as AVCaptureInputPortMBS in a AddCaptureInputPort x next elseif e isa CMFormatDescriptionMBS then dim a() as CMFormatDescriptionMBS = v for each x as CMFormatDescriptionMBS in a AddFormatDescription x next else Break end if end if else // show normal item if v isa AVCaptureDeviceInputMBS then ShowCaptureDeviceInput v elseif v isa AVCaptureDeviceMBS then ShowCaptureDevice v elseif v isa AVCaptureDeviceInputSourceMBS then ShowCaptureDeviceInputSource v elseif v isa AVCaptureDeviceFormatMBS then ShowCaptureDeviceFormat v elseif v isa AVCaptureInputPortMBS then ShowCaptureInportPort v elseif v isa CMFormatDescriptionMBS then ShowFormatDescription v else Break end if end if End EventHandler
End Control
EventHandler Sub Open() Dim devices() As AVCaptureDeviceMBS = AVCaptureDeviceMBS.devices for each d as AVCaptureDeviceMBS in devices AddCaptureDevice d, "Device "+Str(devices.IndexOf(d)) next Dim device1 As AVCaptureDeviceMBS = AVCaptureDeviceMBS.defaultDeviceWithMediaType(AVFoundationMBS.AVMediaTypeVideo) If device1 <> Nil Then AddCaptureDevice device1, "Default Audio Device" End If Dim device2 As AVCaptureDeviceMBS = AVCaptureDeviceMBS.defaultDeviceWithMediaType(AVFoundationMBS.AVMediaTypeAudio) If device2 <> Nil Then AddCaptureDevice device2, "Default Video Device" End If End EventHandler
Sub AddCaptureDevice(d as AVCaptureDeviceMBS, label as string) List.AddFolder label, d List.Cell(List.LastIndex,1) = d.localizedName End Sub
Sub AddCaptureDeviceFormat(d as AVCaptureDeviceFormatMBS) List.AddFolder "Format" List.RowTag(List.LastIndex) = d End Sub
Sub AddCaptureDeviceInput(d as AVCaptureDeviceInputMBS) List.AddFolder "Device Input" List.RowTag(List.LastIndex) = d End Sub
Sub AddCaptureDeviceInputSource(d as AVCaptureDeviceInputSourceMBS) List.AddFolder d.localizedName List.RowTag(List.LastIndex) = d End Sub
Sub AddCaptureInputPort(d as AVCaptureInputPortMBS) List.AddFolder "Input Port" List.RowTag(List.LastIndex) = d End Sub
Sub AddFormatDescription(d as CMFormatDescriptionMBS) list.AddRow "name", d.name End Sub
Sub AddFrameRateRange(d as AVFrameRateRangeMBS, label as string = "") if label = "" then label = "FormatDescription" List.AddFolder label List.RowTag(List.LastIndex) = d End Sub
Sub ShowCaptureDevice(v as AVCaptureDeviceMBS) dim activeFormat as AVCaptureDeviceFormatMBS = v.activeFormat if activeFormat = nil then List.AddRow "activeFormat","nil" else List.AddFolder "activeFormat", activeFormat end if List.AddRow "activeVideoMinFrameDuration", Format(v.activeVideoMinFrameDuration.Seconds,"0.00") List.AddRow "exposureMode", str(v.exposureMode) List.AddRow "exposurePointOfInterest", FormatPoint(v.exposurePointOfInterest) List.AddRow "flashMode", str(v.flashMode) List.AddRow "focusMode", str(v.focusMode) List.AddRow "focusPointOfInterest", FormatPoint(v.focusPointOfInterest) dim formats() as AVCaptureDeviceFormatMBS = v.formats if Formats.Ubound < 0 then list.AddRow "Formats", "n/a" else list.AddFolder "Formats", Formats end if List.AddRow "hasFlash", str(v.hasFlash) List.AddRow "hasTorch", str(v.hasTorch) dim inputSources() as AVCaptureDeviceInputSourceMBS = v.inputSources if inputSources.Ubound < 0 then list.AddRow "inputSources", "n/a" else list.AddFolder "inputSources", inputSources end if List.AddRow "isAdjustingExposure", str(v.isAdjustingExposure) List.AddRow "isAdjustingFocus", str(v.isAdjustingFocus) List.AddRow "isAdjustingWhiteBalance", str(v.isAdjustingWhiteBalance) List.AddRow "isConnected", str(v.isConnected) List.AddRow "isExposurePointOfInterestSupported", str(v.isExposurePointOfInterestSupported) List.AddRow "isFocusPointOfInterestSupported", str(v.isFocusPointOfInterestSupported) List.AddRow "isInUseByAnotherApplication", str(v.isInUseByAnotherApplication) List.AddRow "isSuspended", str(v.isSuspended) dim linkedDevices() as AVCaptureDeviceMBS = v.linkedDevices if linkedDevices.Ubound < 0 then list.AddRow "linkedDevices", "n/a" else list.AddFolder "linkedDevices", linkedDevices end if List.AddRow "localizedName", (v.localizedName) List.AddRow "modelID", (v.modelID) List.AddRow "position", str(v.position) List.AddRow "transportControlsPlaybackMode", str(v.transportControlsPlaybackMode) List.AddRow "transportControlsSpeed", str(v.transportControlsSpeed) List.AddRow "transportControlsSupported", str(v.transportControlsSupported) List.AddRow "transportType", str(v.transportType) List.AddRow "uniqueID", (v.uniqueID) List.AddRow "whiteBalanceMode", str(v.whiteBalanceMode) End Sub
Sub ShowCaptureDeviceFormat(v as AVCaptureDeviceFormatMBS) dim formatDescription as CMFormatDescriptionMBS = v.formatDescription if formatDescription = nil then List.AddRow "formatDescription", "n/a" else List.AddRow "formatDescription", formatDescription.Name 'List.AddFolder "formatDescription", formatDescription end if List.AddRow "mediaType", v.mediaType dim videoSupportedFrameRateRanges() as AVFrameRateRangeMBS = v.videoSupportedFrameRateRanges if videoSupportedFrameRateRanges.Ubound < 0 then list.AddRow "videoSupportedFrameRateRanges", "n/a" else list.AddFolder "videoSupportedFrameRateRanges", videoSupportedFrameRateRanges end if End Sub
Sub ShowCaptureDeviceInput(v as AVCaptureDeviceInputMBS) dim Ports() as AVCaptureInputPortMBS = v.Ports if Ports.Ubound < 0 then list.AddRow "Ports", "n/a" else list.AddFolder "Ports", Ports end if End Sub
Sub ShowCaptureDeviceInputSource(v as AVCaptureDeviceInputSourceMBS) List.AddRow "inputSourceID", v.inputSourceID List.AddRow "localizedName", v.localizedName End Sub
Sub ShowCaptureInportPort(v as AVCaptureInputPortMBS) dim formatDescription as CMFormatDescriptionMBS = v.formatDescription if formatDescription = nil then List.AddRow "formatDescription", "n/a" else List.AddFolder "formatDescription", formatDescription end if List.AddRow "mediaType", v.mediaType List.AddRow "Enabled", str(v.Enabled) End Sub
Sub ShowFormatDescription(v as CMFormatDescriptionMBS) End Sub
Sub ShowFrameRateRange(d as AVFrameRateRangeMBS) List.AddRow "minFrameDuration: "+str(d.minFrameDuration) List.AddRow "maxFrameDuration: "+str(d.maxFrameDuration) List.AddRow "minFrameRate: "+str(d.minFrameRate) List.AddRow "maxFrameRate: "+str(d.maxFrameRate) End Sub
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
Module Module1
Sub AddFolder(extends list as listbox, name as string, tag as Variant) list.AddFolder name list.RowTag(list.LastIndex) = tag End Sub
Function FormatPoint(c as CGPointMBS) As string if c = nil then Return "n/a" else Return str(c.x)+"/"+str(c.y) end if End Function
End Module
ExternalFile info
End ExternalFile
End Project

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


The biggest plugin in space...