# nativescript-advanced-camera

> Camera plugin for NativeScript

Latest version **1.0.1** (published 2021-03-26) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install nativescript-advanced-camera
pnpm add nativescript-advanced-camera
yarn add nativescript-advanced-camera
bun add nativescript-advanced-camera
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2021-03-26 |
| First published | 2021-03-26 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 78.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | CirXe0N |
| Maintainers | cirxe0n |
| Keywords | NativeScript, JavaScript, Angular, Android, iOS |

## Links

- npm: https://www.npmjs.com/package/nativescript-advanced-camera
- Repository: https://github.com/CirXe0N/nativescript-advanced-camera
- Issues: https://github.com/CirXe0N/nativescript-advanced-camera/issues
- npm.io page: https://npm.io/package/nativescript-advanced-camera

## Dependencies (1)

- [ts-node](https://npm.io/package/ts-node.md) ^9.1.1

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 1.0.1 (latest) — 2021-03-26

## README

# 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](#prerequisites)
- [Installation](#installation)
- [Usage](#usage)
- [Features](#features)
- [Properties](#properties)
    - [Common Properties](#common-properties)
    - [iOS Specific Properties](#ios-specific-properties)
- [Methods](#methods)
    - [Common Methods](#common-Methods)
    - [iOS Specific Properties](#ios-specific-methods)

### Prerequisites
* [NativeScript 7+](https://docs.nativescript.org/start/quick-setup)

### Installation
```commandline
$ tns plugin add nativescript-advanced-camera
```

### Usage

#### Angular 11+

HTML Template: `home.component.html`
```html
<AdvancedCamera height="300dp" width="300dp" backgroundColor="black" (loaded)="onLoaded($event)"></AdvancedCamera>
```

Component: `home.component.ts`
```typescript
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.

| Feature                              | Android               | iOS                   |
| ---------------------------------    | :-------------------: | :--------------------:|
| 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

| Property                            | Type      | Description                                                                        |
| ----------------------------------- | :-------: | ---------------------------------------------------------------------------------- | 
| writeFilesToPhoneLibrary            | Boolean   | Enable / Disable saving the files to phone library.                                | 

#### iOS Specific Properties

| Property                            | Type      | Description                                                                          |
| ----------------------------------- | :-------: | ------------------------------------------------------------------------------------ | 
| shouldKeepViewAtOrientationChanges  | Boolean   | Enable / Disable keeping the view with the same bounds when the orientation changes. | 
| shouldRespondToOrientationChanges   | Boolean   | Enable / Disable the video following device orientation.                             | 
| writeFilesToPhoneLibrary            | Boolean   | Enable / Disable saving the files to phone library.                                  | 

### Methods

#### Common Methods

| Method               | Description                                                                            |
| -------------------- | -------------------------------------------------------------------------------------- | 
| record()             | Starts recording a video.                                                              | 
| stop()               | Stops the video recording and returns a Promise that gives the video file. |

#### iOS Specific Methods

| Method               | Description                                                                          |
| -------------------- | ------------------------------------------------------------------------------------ | 
| resetOrientation()   | Reset and redraw the preview layer orientation.                                      |

---
_Source: https://npm.io/package/nativescript-advanced-camera · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
