Platforms to show: All Mac Windows Linux Cross-Platform
/AVFoundation/AVCaptureDevice Authorization
Required plugins for this example: 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/AVCaptureDevice Authorization
This example is the version from Sat, 21th Jun 2019.
Project "AVCaptureDevice Authorization.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Löschen"
Const kFileQuit = "Beenden"
Const kFileQuitShortcut = ""
End Class
Class MainWindow Inherits Window
Control List Inherits Listbox
ControlInstance List Inherits Listbox
End Control
Control AudioButton Inherits PushButton
ControlInstance AudioButton Inherits PushButton
EventHandler Sub Action()
AVCaptureDeviceMBS.requestAccessForMediaType AVFoundationMBS.AVMediaTypeAudio
End EventHandler
End Control
Control VideoButton Inherits PushButton
ControlInstance VideoButton Inherits PushButton
EventHandler Sub Action()
AVCaptureDeviceMBS.requestAccessForMediaType AVFoundationMBS.AVMediaTypeVideo
End EventHandler
End Control
EventHandler Sub Open()
av = new AVFoundation
av.list = list
dim statusAudio as integer = AVCaptureDeviceMBS.authorizationStatusForMediaType(AVFoundationMBS.AVMediaTypeAudio)
dim statusVideo as integer = AVCaptureDeviceMBS.authorizationStatusForMediaType(AVFoundationMBS.AVMediaTypeVideo)
List.AddRow "Status for Audio: "+str(statusAudio)+" "+StatusToText(statusAudio)
List.AddRow "Status for Video: "+str(statusVideo)+" "+StatusToText(statusVideo)
End EventHandler
Function StatusToText(n as integer) As string
Select case n
case AVCaptureDeviceMBS.AVAuthorizationStatusNotDetermined
return "Not Determined"
case AVCaptureDeviceMBS.AVAuthorizationStatusRestricted
return "Restricted"
case AVCaptureDeviceMBS.AVAuthorizationStatusDenied
return "Denied"
case AVCaptureDeviceMBS.AVAuthorizationStatusAuthorized
return "Authorized"
else
return "?"
end Select
End Function
Property av As AVFoundation
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
Class AVFoundation Inherits AVFoundationMBS
EventHandler Sub requestAccessForMediaTypeCompleted(MediaType as String, granted as boolean, tag as variant)
dim grantedText as string
if granted then
grantedText = "granted"
else
grantedText = "denied"
end if
List.AddRow "Status for "+MediaType+": "+grantedText
End EventHandler
Property list As listbox
End Class
ExternalFile info
End ExternalFile
End Project
The items on this page are in the following plugins: MBS AVFoundation Plugin.