* Copyright (c) 2025 Huawei Device Co., Ltd. All rights reserved
* Use of this source code is governed by a MIT license that can be
* found in the LICENSE file.
*/
import React, { useState } from 'react';
import { StyleSheet, Text, Button, ScrollView, View } from 'react-native';
import { createThumbnail } from 'react-native-create-thumbnail';
export default function CreateThumbnailDemo() {
const [text, setText] = useState('');
const CreateThumbnail = async()=> {
let obj = await createThumbnail({
url:'https://media.w3.org/2010/05/sintel/trailer.mp4',
timeStamp: 10000
});
setText(JSON.stringify(obj));
};
return (
<View style={styles.container}>
<View style={styles.titleArea}>
<Text style = {styles.title}>Math</Text>
</View>
<View style = {styles.inputArea}>
<Text style={styles.baseText}>
{text}
</Text>
</View>
<ScrollView style={styles.scrollView}>
<View style={ { flexDirection: 'column'}}>
<View style ={styles.baseArea}>
<Text style= {{flex:1}}>createThumbnail</Text>
<Button title='运行' color='#841584' onPress={CreateThumbnail}></Button>
</View>
</View>
</ScrollView>
</View>
);
}
const styles = StyleSheet.create({
container: {
width: '100%',
height: '100%',
flexDirection: 'column',
alignItems: 'center',
backgroundColor: '#F1F3F5',
},
baseText: {
fontWeight: 'bold',
textAlign:'center',
fontSize:16
},
titleArea:{
width:'90%',
height:'8%',
alignItems:'center',
flexDirection:'row',
},
title: {
width:'90%',
color:'#000000',
textAlign:'left',
fontSize: 30,
},
scrollView: {
width:'90%',
marginHorizontal: 20,
},
inputArea: {
width:'90%',
height:'30%',
borderWidth:2,
borderColor:'#000000',
marginTop:8,
justifyContent:'center',
alignItems:'center',
},
baseArea: {
width:'100%',
height:60,
borderRadius:4,
borderColor:'#000000',
marginTop:8,
backgroundColor:'#FFFFFF',
flexDirection: 'row',
alignItems:'center',
paddingLeft:8,
paddingRight:8
}
});