FutureBasic Logo

<<    Index    >> FutureBasic

AVCaptureView   statement



Syntax
avcaptureview tag, rect, controlsStyle, wndTag

Requires
Tlbx AVKit.incl header.
macOS 10.10+

Description
The avcaptureview statement puts a new avcaptureview in the current output window, or alters an existing avcaptureview's characteristics.

Parameters
Parameter
Description
tag A number (1 through 1000000) that you assign when you create the avcaptureview and that you refer to when altering the view. The number you assign must be different from the tag value of all other existing widgets in the current window. A negative tag hides the view.
rect The view's enclosing rectangle. This can be specified in either of two ways:
(i) (x,y,w,h) where x,y are the origin and w,h the size of the view.
(ii) A CGRect value
controlsStyle The style of the controls that appear over the view.
AVCaptureViewControlsStyleInline
AVCaptureViewControlsStyleFloating
AVCaptureViewControlsStyleInlineDeviceSelection
AVCaptureViewControlsStyleDefault
(default)
wndTag An optional parameter for when the view's window is not the current output window. Note specifying this parameter does not bring the window to the front or make it the output window.
 

Example

include "Tlbx AVKit.incl"

#plist NSMicrophoneUsageDescription @"Your microphone will be used to record sounds." // required
#plist NSCameraUsageDescription @"Your camera will be used to display video." // required

_window = 1
begin enum 1
_captureView
end enum

void local fn BuildWindow
CGRect r = {0,0,814,508}
window _window, @"AVCaptureView", r
avcaptureview _captureView, r
ViewSetAutoresizingMask( _captureView, NSViewWidthSizable + NSViewHeightSizable )
AVCaptureViewSetVideoGravity( _captureView, AVLayerVideoGravityResizeAspectFill )
end fn

void local fn StartRecording( fileOutput as AVCaptureFileOutputRef )
CFURLRef url = fn FileManagerURLForDirectory( NSDesktopDirectory, NSUserDomainMask )
url = fn URLByAppendingPathComponent( url, @"MyVideoFile.m4a" )
AVCaptureFileOutputStartRecordingToURL( fileOutput, url )
end fn

void local fn DoAppEvent( ev as long )
select ( ev )
case _appDidFinishLaunching : fn BuildWindow
case _appShouldTerminateAfterLastWindowClosed : AppEventSetBool( YES )
end select
end fn

void local fn DoDialog( ev as long, tag as long, wnd as long, obj as CFTypeRef )
select ( ev )
case _avCaptureViewStartRecordingToFileOutput : fn StartRecording( obj )// obj is AVCaptureFileOutputRef
end select
end fn

on dialog fn DoDialog
on appevent fn DoAppEvent

HandleEvents

Dialog event
_avCaptureViewStartRecordingToFileOutput


Apple documentation
AVCaptureView