Gathering detailed insights and metrics for @ohmi/react-native-create-thumbnail
Gathering detailed insights and metrics for @ohmi/react-native-create-thumbnail
Gathering detailed insights and metrics for @ohmi/react-native-create-thumbnail
Gathering detailed insights and metrics for @ohmi/react-native-create-thumbnail
npm install @ohmi/react-native-create-thumbnail
Typescript
Module System
Node Version
NPM Version
Total Downloads
404
Last Day
2
Last Week
111
Last Month
306
Last Year
404
Minified
Minified + Gzipped
Latest Version
2.0.0-0.0.8
Package Id
@ohmi/react-native-create-thumbnail@2.0.0-0.0.8
Unpacked Size
80.08 kB
Size
33.78 kB
File Count
69
NPM Version
10.9.2
Node Version
22.14.0
Published on
May 14, 2025
Cumulative downloads
Total Downloads
Last Day
-50%
2
Compared to previous day
Last Week
326.9%
111
Compared to previous week
Last Month
212.2%
306
Compared to previous month
Last Year
0%
404
Compared to previous year
2
2
模板版本:v0.2.0
react-native-create-thumbnail
本项目基于 react-native-create-thumbnail@2.0.0 开发。
[!TIP] Gitee 地址
请到三方库的 Releases 发布地址查看配套的版本信息:@ohmi/react-native-create-thumbnail Releases 。对于未发布到npm的旧版本,请参考安装指南安装tgz包。
进入到工程目录并输入以下命令:
1npm install @ohmi/react-native-create-thumbnail
1yarn add @ohmi/react-native-create-thumbnail
下面的代码展示了这个库的基本使用场景:
[!WARNING] 使用时 import 的库名不变。
1import React, {useState } from 'react'; 2import { StyleSheet, Text, Button ,ScrollView,View} from 'react-native'; 3import { createThumbnail } from 'react-native-create-thumbnail'; 4 5// 导出组件 6export default function CreateThumbnailDemo() { 7 8 const [text, setText] = useState(''); 9 10 const CreateThumbnail = async()=> { 11 let obj = await createThumbnail({ 12 url:'https://media.w3.org/2010/05/sintel/trailer.mp4', 13 timeStamp: 10000 14 }); 15 setText(JSON.stringify(obj)) 16 } 17 18 return ( 19 <View style={styles.container}> 20 <View style={styles.titleArea}> 21 <Text style = {styles.title}>Math</Text> 22 </View> 23 <View style = {styles.inputArea}> 24 <Text style={styles.baseText}> 25 {text} 26 </Text> 27 </View> 28 <ScrollView style={styles.scrollView}> 29 <View style={ { flexDirection: 'column'}}> 30 <View style ={styles.baseArea}> 31 <Text style= {{flex:1}}>createThumbnail</Text> 32 <Button title='运行' color='#841584' onPress={CreateThumbnail}></Button> 33 </View> 34 35 </View> 36 </ScrollView> 37 </View> 38 ); 39} 40 41const styles = StyleSheet.create({ 42 container: { 43 width: '100%', 44 height: '100%', 45 flexDirection: 'column', 46 alignItems: 'center', 47 backgroundColor: '#F1F3F5', 48 }, 49 baseText: { 50 fontWeight: 'bold', 51 textAlign:'center', 52 fontSize:16 53 }, 54 55 titleArea:{ 56 width:'90%', 57 height:'8%', 58 alignItems:'center', 59 flexDirection:'row', 60 }, 61 62 title: { 63 width:'90%', 64 color:'#000000', 65 textAlign:'left', 66 fontSize: 30, 67 }, 68 69 scrollView: { 70 width:'90%', 71 marginHorizontal: 20, 72 }, 73 74 inputArea: { 75 width:'90%', 76 height:'30%', 77 borderWidth:2, 78 borderColor:'#000000', 79 marginTop:8, 80 justifyContent:'center', 81 alignItems:'center', 82 }, 83 baseArea: { 84 width:'100%', 85 height:60, 86 borderRadius:4, 87 borderColor:'#000000', 88 marginTop:8, 89 backgroundColor:'#FFFFFF', 90 flexDirection: 'row', 91 alignItems:'center', 92 paddingLeft:8, 93 paddingRight:8 94 } 95});
目前 HarmonyOS 暂不支持 AutoLink,所以 Link 步骤需要手动配置。
首先需要使用 DevEco Studio 打开项目里的 HarmonyOS 工程 harmony
oh-package.json5
添加 overrides 字段1{ 2 ... 3 "overrides": { 4 "@rnoh/react-native-openharmony" : "./react_native_openharmony" 5 } 6}
目前有两种方法:
方法一:通过 har 包引入
[!TIP] har 包位于三方库安装路径的
harmony
文件夹下。
打开 entry/oh-package.json5
,添加以下依赖
1"dependencies": { 2 "@rnoh/react-native-openharmony": "file:../react_native_openharmony", 3 "@ohmi/react-native-create-thumbnail": "file:../../node_modules/@ohmi/react-native-create-thumbnail/harmony/createThumbnail.har" 4 }
点击右上角的 sync
按钮
或者在终端执行:
1cd entry 2ohpm install
方法二:直接链接源码
[!TIP] 源码位于三方库安装路径的
harmony
文件夹下。
打开 entry/oh-package.json5
,添加以下依赖
1"dependencies": { 2 "@rnoh/react-native-openharmony": "file:../react_native_openharmony", 3 "@ohmi/react-native-create-thumbnail": "file:../../node_modules/@ohmi/react-native-create-thumbnail/harmony/createThumbnail" 4 }
打开终端,执行:
1cd entry 2ohpm install --no-link
打开 entry/src/main/ets/RNPackagesFactory.ts
,添加:
1 ... 2+ import { CreateThumbnailPackage } from '@ohmi/react-native-create-thumbnail/ts'; 3 4export function createRNPackages(ctx: RNPackageContext): RNPackage[] { 5 return [ 6 new SamplePackage(ctx), 7+ new CreateThumbnailPackage(ctx) 8 ]; 9}
打开 entry/src/main/cpp/CMakeLists.txt
,添加:
1project(rnapp) 2cmake_minimum_required(VERSION 3.4.1) 3set(CMAKE_SKIP_BUILD_RPATH TRUE) 4set(RNOH_APP_DIR "${CMAKE_CURRENT_SOURCE_DIR}") 5set(NODE_MODULES "${CMAKE_CURRENT_SOURCE_DIR}/../../../../../node_modules") 6+ set(OH_MODULES "${CMAKE_CURRENT_SOURCE_DIR}/../../../oh_modules") 7set(RNOH_CPP_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../react-native-harmony/harmony/cpp") 8set(LOG_VERBOSITY_LEVEL 1) 9set(CMAKE_ASM_FLAGS "-Wno-error=unused-command-line-argument -Qunused-arguments") 10set(CMAKE_CXX_FLAGS "-fstack-protector-strong -Wl,-z,relro,-z,now,-z,noexecstack -s -fPIE -pie") 11set(WITH_HITRACE_SYSTRACE 1) # for other CMakeLists.txt files to use 12add_compile_definitions(WITH_HITRACE_SYSTRACE) 13 14add_subdirectory("${RNOH_CPP_DIR}" ./rn) 15 16# RNOH_BEGIN: manual_package_linking_1 17add_subdirectory("../../../../sample_package/src/main/cpp" ./sample-package) 18+ add_subdirectory("${OH_MODULES}/@ohmi/react-native-create-thumbnail/src/main/cpp" ./create_thumbnail) 19# RNOH_END: manual_package_linking_1 20 21file(GLOB GENERATED_CPP_FILES "./generated/*.cpp") 22 23add_library(rnoh_app SHARED 24 ${GENERATED_CPP_FILES} 25 "./PackageProvider.cpp" 26 "${RNOH_CPP_DIR}/RNOHAppNapiBridge.cpp" 27) 28target_link_libraries(rnoh_app PUBLIC rnoh) 29 30# RNOH_BEGIN: manual_package_linking_2 31target_link_libraries(rnoh_app PUBLIC rnoh_sample_package) 32+ target_link_libraries(rnoh_app PUBLIC rnoh_create_thumbnail) 33# RNOH_END: manual_package_linking_2
打开 entry/src/main/cpp/PackageProvider.cpp
,添加:
1#include "RNOH/PackageProvider.h" 2#include "generated/RNOHGeneratedPackage.h" 3#include "SamplePackage.h" 4+ #include "RNCreateThumbnailPackage.h" 5 6using namespace rnoh; 7 8std::vector<std::shared_ptr<Package>> PackageProvider::getPackages(Package::Context ctx) { 9 return { 10 std::make_shared<RNOHGeneratedPackage>(ctx), 11 std::make_shared<SamplePackage>(ctx), 12+ std::make_shared<RNCreateThumbnailPackage>(ctx), 13 }; 14}
点击右上角的 sync
按钮
或者在终端执行:
1cd entry 2ohpm install
然后编译、运行即可。
要使用此库,需要使用正确的 React-Native 和 RNOH 版本。另外,还需要使用配套的 DevEco Studio 和 手机 ROM。
请到三方库相应的 Releases 发布地址查看 Release 配套的版本信息:@ohmi/react-native-create-thumbnail Releases
[!TIP] "Platform"列表示该属性在原三方库上支持的平台。
[!TIP] "HarmonyOS Support"列为 yes 表示 HarmonyOS 平台支持该属性;no 则表示不支持;partially 表示部分支持。使用方法跨平台一致,效果对标 iOS 或 Android 的效果。
Name | Description | Type | Required | HarmonyOS Support |
---|---|---|---|---|
createThumbnail | thumbnail generator with storage/cache management and support for both local and remote videos | function | NO | yes |
[!TIP] "Platform"列表示该属性在原三方库上支持的平台。
[!TIP] "HarmonyOS Support"列为 yes 表示 HarmonyOS 平台支持该属性;no 则表示不支持;partially 表示部分支持。使用方法跨平台一致,效果对标 iOS 或 Android 的效果。
Name | Description | type | Required | Platform | HarmonyOS Support |
---|---|---|---|---|---|
url | Path to video file (local or remote) | String | yes | Android/ios | yes |
timeStamp | Thumbnail timestamp (in milliseconds) | Number | NO | Android/ios | yes |
format | Thumbnail format, can be one of: jpeg, or png | String | NO | Android/ios | yes |
dirSize | 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. | Number | NO | Android/ios | yes |
headers | Headers to load the video with. e.g. { Authorization: 'someAuthToken' } | Object | NO | Android/ios | yes |
cacheName | 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. | String | NO | Android/ios | yes |
[!TIP] "Platform"列表示该属性在原三方库上支持的平台。
[!TIP] "HarmonyOS Support"列为 yes 表示 HarmonyOS 平台支持该属性;no 则表示不支持;partially 表示部分支持。使用方法跨平台一致,效果对标 iOS 或 Android 的效果。
Name | Description | type | Required | Platform | HarmonyOS Support |
---|---|---|---|---|---|
path | Path to generated thumbnail | String | NO | Android/ios | yes |
size | Size (in bytes) of thumbnail | Number | NO | Android/ios | yes |
mime | Mimetype of thumbnail | String | NO | Android/ios | yes |
width | Thumbnail width | Number | NO | Android/ios | yes |
height | Thumbnail height | Number | NO | Android/ios | yes |
本项目基于 The MIT License (MIT) ,请自由地享受和参与开源。
No vulnerabilities found.
No security vulnerabilities found.