|
1 |
| -# react-native-create-thumbnail |
| 1 | +# @react-native-oh-tpl/react-native-create-thumbnail |
2 | 2 |
|
3 |
| -iOS/Android thumbnail generator with storage/cache management and support for both local and remote videos. `react-native-create-thumbnail` is a wrapper around |
4 |
| -[`AVAssetImageGenerator`](https://developer.apple.com/documentation/avfoundation/avassetimagegenerator?language=objc) (iOS) and [`MediaMetadataRetriever`](https://developer.android.com/reference/android/media/MediaMetadataRetriever) (Android) |
| 3 | +本项目基于 [react-native-create-thumbnail](https://github.com/souvik-ghosh/react-native-create-thumbnail) |
5 | 4 |
|
6 |
| -[](https://npmjs.com/package/react-native-create-thumbnail) [](https://npmjs.com/package/react-native-create-thumbnail) [](#maintenance-status) |
| 5 | +## 文档地址 Documentation URL |
7 | 6 |
|
8 |
| -## Getting started |
| 7 | +[中文 Chinese](https://gitee.com/react-native-oh-library/usage-docs/blob/master/zh-cn/react-native-create-thumbnail.md) |
9 | 8 |
|
10 |
| -1. Install library from `npm` |
| 9 | +[英文 English](https://gitee.com/react-native-oh-library/usage-docs/blob/master/zh-en/react-native-create-thumbnail.md) |
11 | 10 |
|
12 |
| - ```bash |
13 |
| - npm i react-native-create-thumbnail |
14 |
| - ``` |
| 11 | +## 请悉知 Acknowledgements |
15 | 12 |
|
16 |
| - or |
17 |
| - |
18 |
| - ```bash |
19 |
| - yarn add react-native-create-thumbnail |
20 |
| - ``` |
21 |
| - |
22 |
| -2. Link native code |
23 |
| - |
24 |
| - With autolinking (react-native 0.60+) |
25 |
| - |
26 |
| - ```bash |
27 |
| - cd ios && pod install |
28 |
| - ``` |
29 |
| - |
30 |
| - Pre 0.60 |
31 |
| - |
32 |
| - ```bash |
33 |
| - react-native link react-native-create-thumbnail |
34 |
| - ``` |
35 |
| - |
36 |
| -## Usage |
37 |
| - |
38 |
| -```javascript |
39 |
| -import { createThumbnail } from "react-native-create-thumbnail"; |
40 |
| - |
41 |
| -createThumbnail({ |
42 |
| - url: '<path to video file>', |
43 |
| - timeStamp: 10000, |
44 |
| -}) |
45 |
| - .then(response => console.log({ response })) |
46 |
| - .catch(err => console.log({ err })); |
47 |
| -``` |
48 |
| - |
49 |
| -## Request Object |
50 |
| - |
51 |
| -| Property | Type | Description | |
52 |
| -| --------- | :-----------------------: | :------------------------------------------------------------------------ | |
53 |
| -| url | `String` (required) | Path to video file (local or remote) | |
54 |
| -| timeStamp | `Number` (default `0`) | Thumbnail timestamp (in milliseconds) | |
55 |
| -| format | `String` (default `jpeg`) | Thumbnail format, can be one of: `jpeg`, or `png` | |
56 |
| -| dirSize | `Number` (default `100`) | Maximum size of the cache directory (in megabytes). When this directory is full, the previously generated thumbnails will be deleted to clear about half of it's size. | |
57 |
| -| headers | `Object` | Headers to load the video with. e.g. `{ Authorization: 'someAuthToken' }` | |
58 |
| -| cacheName | `String` (optional) | Cache name for this thumbnail to avoid duplicate generation. If specified, and a thumbnail already exists with the same cache name, it will be returned instead of generating a new one. | |
59 |
| - |
60 |
| -## Response Object |
61 |
| - |
62 |
| -| Property | Type | Description | |
63 |
| -| -------- | :------: | :-------------------------- | |
64 |
| -| path | `String` | Path to generated thumbnail | |
65 |
| -| size | `Number` | Size (in bytes) of thumbnail| |
66 |
| -| mime | `String` | Mimetype of thumbnail | |
67 |
| -| width | `Number` | Thumbnail width | |
68 |
| -| height | `Number` | Thumbnail height | |
69 |
| - |
70 |
| -#### Notes |
71 |
| - |
72 |
| -Requires following Permissions on android |
73 |
| - |
74 |
| -```bash |
75 |
| -READ_EXTERNAL_STORAGE, WRITE_EXTERNAL_STORAGE |
76 |
| -``` |
77 |
| - |
78 |
| -#### Limitations |
79 |
| - |
80 |
| -- Remote videos aren't supported on android sdk_version < 14. |
81 |
| -- This is a **Native Module**, so it won't work in expo managed projects. |
82 |
| -- This library heavily depends on the native API's to generate the thumbnails. Thus it can only generate from the video formats/codecs that are supported by the device's OS. |
83 |
| - |
84 |
| -#### Credits |
85 |
| - |
86 |
| -- [`react-native-thumbnail`](https://www.npmjs.com/package/react-native-thumbnail) - A great source of inspiration |
87 |
| -- This project was bootstrapped with [`create-react-native-module`](https://github.com/brodybits/create-react-native-module) |
88 |
| - |
89 |
| -#### Maintenance Status |
90 |
| - |
91 |
| -**Active:** Bug reports, feature requests and pull requests are welcome. |
| 13 | +本项目基于 [The MIT License (MIT)](https://github.com/souvik-ghosh/react-native-create-thumbnail/blob/master/LICENSE) ,请自由地享受和参与开源。 |
0 commit comments