Skip to content

Latest commit

 

History

History
101 lines (79 loc) · 3.89 KB

README.md

File metadata and controls

101 lines (79 loc) · 3.89 KB

PBJVision

Vision

Vision is an iOS camera engine that supports touch-to-record video, slow motion video (120 fps for supporting hardware, which is currently only iPhone 5S), and photo capture. It is compatible with both iOS 7 and iOS 8 but also supports 64-bit. Pause and resume video capture is also possible without having to use a touch gesture as the sample project provides.

iOS 6 is supported in versions v0.3.2 and below but may slowly start dropping support future.

I created this component at DIY as a fun means for kids to author video and share their skills. This same recording interaction was pioneered by Vine and also Instagram.

Please review the release history for a summary of the latest changes and more information.

Build Status

Installation

CocoaPods is the recommended method of installing PBJVision, just add the following line to your Podfile:

pod 'PBJVision'

Usage

#import "PBJVision.h"
- (void)_setup
{
    _longPressGestureRecognizer.enabled = YES;

    PBJVision *vision = [PBJVision sharedInstance];
    vision.delegate = self;
    [vision setCameraMode:PBJCameraModeVideo];
    [vision setCameraDevice:PBJCameraDeviceBack];
    [vision setCameraOrientation:PBJCameraOrientationPortrait];
    [vision setFocusMode:PBJFocusModeAutoFocus];

    [vision startPreview];
}
- (void)_handleLongPressGestureRecognizer:(UIGestureRecognizer *)gestureRecognizer
{
    switch (gestureRecognizer.state) {
      case UIGestureRecognizerStateBegan:
        {
            if (!_recording)
                [[PBJVision sharedInstance] startVideoCapture];
            else
                [[PBJVision sharedInstance] resumeVideoCapture];
            break;
        }
      case UIGestureRecognizerStateEnded:
      case UIGestureRecognizerStateCancelled:
      case UIGestureRecognizerStateFailed:
        {
            [[PBJVision sharedInstance] pauseVideoCapture];
            break;
        }
      default:
        break;
    }
}
- (void)_handleDoneButton:(UIButton *)button
{
    [self _endCapture];
}
- (void)vision:(PBJVision *)vision capturedVideo:(NSDictionary *)videoDict error:(NSError *)error
{   
    NSString *videoPath = [_currentVideo  objectForKey:PBJVisionVideoPathKey];
    [_assetLibrary writeVideoAtPathToSavedPhotosAlbum:[NSURL URLWithString:videoPath] completionBlock:^(NSURL *assetURL, NSError *error1) {
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle: @"Saved!" message: @"Saved to the camera roll."
                                                       delegate:self
                                              cancelButtonTitle:nil
                                              otherButtonTitles:@"OK", nil];
        [alert show];
    }];
}

Resources

Contributing

See the CONTRIBUTING file for information on how to collaborate and help out. The github issues page is a the place to file a bug, Stack Overflow is a great place to start a discussion and also allows others to benefit and chime-in too.

License

PBJVision is available under the MIT license, see the LICENSE file for more information.