Skip to content

Commit

Permalink
Add Example usago to Readme
Browse files Browse the repository at this point in the history
  • Loading branch information
dragermrb authored Oct 7, 2023
1 parent 47beba9 commit 7c0ea7c
Showing 1 changed file with 54 additions and 2 deletions.
56 changes: 54 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ npx cap sync
### or for Capacitor 4.x

```bash
pm install @whiteguru/capacitor-plugin-video-editor@^4.0.4
npm install @whiteguru/capacitor-plugin-video-editor@^4.0.4
npx cap sync
```

### or for Capacitor 3.x

```bash
pm install @whiteguru/capacitor-plugin-video-editor@^3.0.1
npm install @whiteguru/capacitor-plugin-video-editor@^3.0.1
npx cap sync
```

Expand All @@ -43,6 +43,58 @@ The storage permissions are for reading video files.

Read about [Setting Permissions](https://capacitorjs.com/docs/android/configuration#setting-permissions) in the [Android Guide](https://capacitorjs.com/docs/android) for more information on setting Android permissions.

## Example

```typescript
import { VideoEditor, MediaFileResult } from '@whiteguru/capacitor-plugin-video-editor';

const sourceVideoPath =
'file:///var/mobile/Containers/Data/...../sourceVideo.mp4';

// Transcode with progress
const progressListener = await VideoEditor.addListener(
'transcodeProgress',
(info) => console.log('info', info)
);

VideoEditor.edit({
path: sourceVideoPath,
transcode: {
width: 720,
height: 480,
keepAspectRatio: true,
},
trim: {
startsAt: 3 * 1000, // from 00:03
endsAt: 10 * 1000, // to 00:10
},
}).then(
(mediaFileResult: MediaFileResult) => {
progressListener.remove();

console.log('mediaPath', mediaFileResult.file.path);
},
(error) => {
console.error('error', error);
}
);

// Thumbnail
VideoEditor.thumbnail({
path: sourceVideoPath,
width: 150,
height: 150,
at: 4 * 1000, // at 00:04
}).then(
(thumbMediaFileResult: MediaFileResult) => {
console.log('thumbPath', thumbMediaFileResult.file.path);
},
(error) => {
console.error('error', error);
}
);
```

## API

<docgen-index>
Expand Down

0 comments on commit 7c0ea7c

Please sign in to comment.