Media

ARGear provides photo capture and video recording features through ARGMedia in ratios of 16:9, 4:3, 1:1.

Before using camera functions, video device information should be provided to ARGMedia Class.

Sample code below shows how to set relevant information.

<Sample Code. Setting Video Device Information in ARGMedia Class>
// videoDevice: AVCaptureDevice
// videoDeviceOrientation: AVCaptureVideoOrientation
// videoConnection: AVCaptureConnection
// mediaRatio: ARGMediaRatio
// videoBitrate: ARGMediaVideoBitrate
ARGMedia *argMedia = [[ARGMedia alloc] init];
[argMedia setVideoDevice:device];
[argMedia setVideoDeviceOrientation:AVCaptureVideoOrientationPortrait];
[argMedia setVideoConnection:videoConnection];
[argMedia setMediaRatio:ARGMediaRatio_4x3];
[argMedia setVideoBitrate:ARGMediaVideoBitrate_2M];

Take a Photo

Using the takePicture function in ARGMedia, users can take a photo. After captured a photo, the photo is converted into UIImage type.

Sample code below shows how to get the captured photo.

<Sample Code. Getting a Captured Image>
UIImageView *imageView = [[UIImageView alloc] init];
[_argMedia takePic:^(UIImage * _Nonnull image) {
[imageView setImage:image];
}];

Record a Video

By calling recordVideoStart and recordVideoStop method in ARGMedia class, you can start or stop video recording. Recorded video should be converted into NSDictionary form.

Sample code below shows how to obtain a recorded video.

<Sample Code. Start and Stop Video Recording>
ARGMedia *argMedia = [[ARGMedia alloc] init];
// Start Video Recording
[argMedia recordVideoStart:^(CGFloat recTime) {
dispatch_async(dispatch_get_main_queue(), ^{
// recTime represents recorded time
});
}];
// Stop Video Recording
[argMedia recordVideoStop:^(NSDictionary * _Nonnull videoInfo) {
} save:^(NSDictionary * _Nonnull videoInfo) {
// converting video data into NSDictionary form
}];