1.0.1 • Published 3 years ago

nativescript-advanced-camera v1.0.1

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
3 years ago

NativeScript Advanced Camera

A highly customizable NativeScript camera plugin that can easily be embedded in a view.

NOTES:

  • This plugin is still in development, so for now forget highly customizable. 🙂
  • For feature requests and bugs, feel free to open a new issue.

Table of contents:

Prerequisites

Installation

$ tns plugin add nativescript-advanced-camera

Usage

Angular 11+

HTML Template: home.component.html

<AdvancedCamera height="300dp" width="300dp" backgroundColor="black" (loaded)="onLoaded($event)"></AdvancedCamera>

Component: home.component.ts

import {EventData, isIOS} from "@nativescript/core";
import {AdvancedCamera} from "nativescript-advanced-camera";

registerElement('AdvancedCamera', () => AdvancedCamera);

@Component({
    selector: "Home",
    templateUrl: "./home.component.html"
})
export class HomeComponent {
    private cam: AdvancedCamera;

    public onLoaded(event: EventData) {
        console.log('Cam Loaded');
        this.cam = <AdvancedCamera> event.object;
    }
    
    public record(): void {
        console.log('Start Recording');
        this.cam.record();
    }

    public stop(): void {
        console.log('Stop Recording');
        this.cam.stop().then((file) => {
            const path = isIOS ? file.path : file.getPath();
            console.log(path);
        });
    }
}

Features

Note: To add features to this list, feel free to open a new issue.

FeatureAndroidiOS
Start & Stop Video Recording:heavy_check_mark::heavy_check_mark:
Take Photos:x::x:
Write Video / Photos to Library:heavy_check_mark::heavy_check_mark:
Switch between Front / Back Camera:x::x:

Properties

Common Properties

PropertyTypeDescription
writeFilesToPhoneLibraryBooleanEnable / Disable saving the files to phone library.

iOS Specific Properties

PropertyTypeDescription
shouldKeepViewAtOrientationChangesBooleanEnable / Disable keeping the view with the same bounds when the orientation changes.
shouldRespondToOrientationChangesBooleanEnable / Disable the video following device orientation.
writeFilesToPhoneLibraryBooleanEnable / Disable saving the files to phone library.

Methods

Common Methods

MethodDescription
record()Starts recording a video.
stop()Stops the video recording and returns a Promise that gives the video file.

iOS Specific Methods

MethodDescription
resetOrientation()Reset and redraw the preview layer orientation.