Skip to content

fix: 修复 react-native-create-thumbnail 网络请求异常问题 #6

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 1 commit into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 0 additions & 25 deletions .github/ISSUE_TEMPLATE/bug_report.md

This file was deleted.

17 changes: 0 additions & 17 deletions .github/ISSUE_TEMPLATE/stale.yml

This file was deleted.

92 changes: 7 additions & 85 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,91 +1,13 @@
# react-native-create-thumbnail
# @react-native-oh-tpl/react-native-create-thumbnail

iOS/Android thumbnail generator with storage/cache management and support for both local and remote videos. `react-native-create-thumbnail` is a wrapper around
[`AVAssetImageGenerator`](https://developer.apple.com/documentation/avfoundation/avassetimagegenerator?language=objc) (iOS) and [`MediaMetadataRetriever`](https://developer.android.com/reference/android/media/MediaMetadataRetriever) (Android)
本项目基于 [react-native-create-thumbnail](https://github.com/souvik-ghosh/react-native-create-thumbnail)

[![npm version](https://img.shields.io/npm/v/react-native-create-thumbnail.svg)](https://npmjs.com/package/react-native-create-thumbnail) [![npm downloads](https://img.shields.io/npm/dm/react-native-create-thumbnail.svg)](https://npmjs.com/package/react-native-create-thumbnail) [![Maintenance Status](https://img.shields.io/badge/maintenance-active-green.svg)](#maintenance-status)
## 文档地址 Documentation URL

## Getting started
[中文 Chinese](https://gitee.com/react-native-oh-library/usage-docs/blob/master/zh-cn/react-native-create-thumbnail.md)

1. Install library from `npm`
[英文 English](https://gitee.com/react-native-oh-library/usage-docs/blob/master/zh-en/react-native-create-thumbnail.md)

```bash
npm i react-native-create-thumbnail
```
## 请悉知 Acknowledgements

or

```bash
yarn add react-native-create-thumbnail
```

2. Link native code

With autolinking (react-native 0.60+)

```bash
cd ios && pod install
```

Pre 0.60

```bash
react-native link react-native-create-thumbnail
```

## Usage

```javascript
import { createThumbnail } from "react-native-create-thumbnail";

createThumbnail({
url: '<path to video file>',
timeStamp: 10000,
})
.then(response => console.log({ response }))
.catch(err => console.log({ err }));
```

## Request Object

| Property | Type | Description |
| --------- | :-----------------------: | :------------------------------------------------------------------------ |
| url | `String` (required) | Path to video file (local or remote) |
| timeStamp | `Number` (default `0`) | Thumbnail timestamp (in milliseconds) |
| format | `String` (default `jpeg`) | Thumbnail format, can be one of: `jpeg`, or `png` |
| 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. |
| headers | `Object` | Headers to load the video with. e.g. `{ Authorization: 'someAuthToken' }` |
| 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. |

## Response Object

| Property | Type | Description |
| -------- | :------: | :-------------------------- |
| path | `String` | Path to generated thumbnail |
| size | `Number` | Size (in bytes) of thumbnail|
| mime | `String` | Mimetype of thumbnail |
| width | `Number` | Thumbnail width |
| height | `Number` | Thumbnail height |

#### Notes

Requires following Permissions on android

```bash
READ_EXTERNAL_STORAGE, WRITE_EXTERNAL_STORAGE
```

#### Limitations

- Remote videos aren't supported on android sdk_version < 14.
- This is a **Native Module**, so it won't work in expo managed projects.
- 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.

#### Credits

- [`react-native-thumbnail`](https://www.npmjs.com/package/react-native-thumbnail) - A great source of inspiration
- This project was bootstrapped with [`create-react-native-module`](https://github.com/brodybits/create-react-native-module)

#### Maintenance Status

**Active:** Bug reports, feature requests and pull requests are welcome.
本项目基于 [The MIT License (MIT)](https://github.com/souvik-ghosh/react-native-create-thumbnail/blob/master/LICENSE) ,请自由地享受和参与开源。
Binary file modified harmony/createThumbnail.har
Binary file not shown.
19 changes: 15 additions & 4 deletions harmony/createThumbnail/BuildProfile.ets
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
/**
* Use these variables when you tailor your ArkTS code. They must be of the const type.
*/
export const HAR_VERSION = '2.0.0-0.0.1';
export const BUILD_MODE_NAME = 'debug';
export const DEBUG = true;
export const TARGET_NAME = 'default';

/**
* BuildProfile Class is used only for compatibility purposes.
*/
export default class BuildProfile {
static readonly HAR_VERSION = '2.0.0-0.0.1';
static readonly BUILD_MODE_NAME = 'debug';
static readonly DEBUG = true;
static readonly TARGET_NAME = 'default';
static readonly HAR_VERSION = HAR_VERSION;
static readonly BUILD_MODE_NAME = BUILD_MODE_NAME;
static readonly DEBUG = DEBUG;
static readonly TARGET_NAME = TARGET_NAME;
}
18 changes: 0 additions & 18 deletions harmony/createThumbnail/oh-package-lock.json5

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ export default class RequestDownload {
let downloadConfig: request.agent.Config = {
action: request.agent.Action.DOWNLOAD,
url: url,
method: 'POST',
title: 'download',
mode: request.agent.Mode.FOREGROUND,
network: request.agent.Network.ANY,
Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
"keywords": [
"react-native"
],
"harmony":{
"alias":"react-native-create-thumbnail",
"harmony": {
"alias": "react-native-create-thumbnail",
"codegenConfig": {
"specPaths": [
"./src"
]
}
},
},
"author": {
"name": "Souvik Ghosh",
"email": "emailtosvk@gmail.com"
Expand All @@ -29,6 +29,6 @@
"readmeFilename": "README.md",
"peerDependencies": {
"react-native": ">=0.59.0",
"react-native-create-thumbnail": "2.0.0"
"react-native-create-thumbnail": "2.0.0"
}
}
}