thirdStep.js
7.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
/**
* Created by xiniu on 2018/11/6.
*/
import React, {Component} from 'react';
import {Dimensions, Image, Platform, StatusBar, StyleSheet, Text, TouchableOpacity, View} from 'react-native';
import Slider from 'react-native-slider';
import {observer} from 'mobx-react';
import {getFooterBottom, getHomeColor} from '../../utils/utils';
import uploadVideoThirdLogic from './logic/uploadVideoThirdLogic';
import {zoomH} from "../../utils/getSize";
const zoomW = 750 / parseInt(Dimensions.get('window').width);
@observer
export default class UploadVideoThirdStep extends Component {
static navigationOptions = ({ navigation, screenProps }) => ({
headerStyle: {
height: 40,
elevation: 0, // 去掉阴影
borderBottomWidth: 0,
backgroundColor: "#000"
},
headerTitleStyle: {
flex: 1,
textAlign: "center",
alignSelf: "center",
alignItems: "center",
justifyContent: "center",
flexDirection: "column",
color: "#fff",
fontSize: 18,
},
title: '编辑封面',
headerLeft: (
<TouchableOpacity activeOpacity={0.8} style={styles.backWrap} onPress={() => { navigation.goBack(); navigation.state.params.callBack(true); }}>
<Image source={require('../../img/closeWhite.png')} style={{ width: 31 / zoomW, height: 16.5 }} resizeMode="contain" />
</TouchableOpacity>
),
headerRight: (
<TouchableOpacity activeOpacity={0.8} style={styles.rightWrap} onPress={() => navigation.state.params.saveCover()}>
<Text style={{ fontSize: 16, color: '#fff' }}>完成</Text>
</TouchableOpacity>
),
});
logic = new uploadVideoThirdLogic();
constructor(props) {
super(props);
this.state = {
videoUrl: this.props.navigation.state.params.videoUrl || '',
videoDuration: this.props.navigation.state.params.videoDuration || 0,
currentTime: this.props.navigation.state.params.videoCoverTime || 0,
threadVideoDirection: this.props.navigation.state.params.threadVideoDirection || 0,
};
}
componentWillMount() {
this.logic.moveSlider(this.state.currentTime, this.state.videoDuration);
}
componentDidMount() {
this.props.navigation.setParams({
saveCover: () => this.saveCover(),
});
}
// 进度条值改变
onSliderValueChanged(currentTime) {
this.logic.moveSlider(currentTime, this.state.videoDuration);
}
// 保存视频封面图
saveCover() {
const url = this.state.videoUrl + '?x-oss-process=video/snapshot,t_' + parseInt(this.logic.currentTime * 1000) + ',f_png,w_375,h_0';
this.props.navigation.goBack();
this.props.navigation.state.params.callBack(true);
this.props.navigation.state.params.setCover(url, this.logic.currentTime);
}
render() {
return (
<View style={styles.container}>
<StatusBar
backgroundColor={'#000'}
barStyle={'light-content'}
networkActivityIndicatorVisible
/>
<View style={styles.imageWrap}>
<Image source={{ uri: this.state.videoUrl + '?x-oss-process=video/snapshot,t_' + parseInt(this.logic.currentTime * 1000) + ',f_png,w_375,h_0'}} style={{ width: '100%', height: '100%', transform:[{rotate:this.state.threadVideoDirection + 'deg'}]}} resizeMode="contain" />
</View>
<View style={styles.controlWrap}>
<View style={{ height: 37.5, justifyContent: 'center' }}>
<Text style={{ fontSize: 14, color: 'rgba(255,255,255,.45)' }}>滑动选择封面图</Text>
</View>
<View style={{ width: 630 / zoomW, height: 63, flexDirection: 'row' }}>
<Image source={{ uri: this.state.videoUrl + '?x-oss-process=video/snapshot,t_0,f_png,w_375,h_0'}} style={{ width: 126 / zoomW, height: '100%' , transform:[{rotate:this.state.threadVideoDirection + 'deg'}]}} resizeMode="cover" />
<Image source={{ uri: this.state.videoUrl + '?x-oss-process=video/snapshot,t_' + parseInt(this.state.videoDuration / 4 * 1000) + ',f_png,w_375,h_0'}} style={{ width: 126 / zoomW, height: '100%' , transform:[{rotate:this.state.threadVideoDirection + 'deg'}]}} resizeMode="cover" />
<Image source={{ uri: this.state.videoUrl + '?x-oss-process=video/snapshot,t_' + parseInt(this.state.videoDuration / 2 * 1000) + ',f_png,w_375,h_0'}} style={{ width: 126 / zoomW, height: '100%' , transform:[{rotate:this.state.threadVideoDirection + 'deg'}]}} resizeMode="cover" />
<Image source={{ uri: this.state.videoUrl + '?x-oss-process=video/snapshot,t_' + parseInt(this.state.videoDuration / 4 * 3000) + ',f_png,w_375,h_0'}} style={{ width: 126 / zoomW, height: '100%' , transform:[{rotate:this.state.threadVideoDirection + 'deg'}]}} resizeMode="cover" />
<Image source={{ uri: this.state.videoUrl + '?x-oss-process=video/snapshot,t_' + parseInt(this.state.videoDuration * 1000) + ',f_png,w_375,h_0'}} style={{ width: 126 / zoomW, height: '100%' , transform:[{rotate:this.state.threadVideoDirection + 'deg'}]}} resizeMode="cover" />
<View style={[styles.borderView, { left: this.logic.left,borderColor: global.homeColor, }]}></View>
</View>
<View style={{ width: 557 / zoomW, height: 56.5, justifyContent: 'center' }}>
<Slider
style={{ width: '100%', height: 35.5 }}
minimumTrackTintColor={'transparent'}
maximumTrackTintColor={'transparent'}
thumbStyle={{
width: 55 / zoomW,
height: 35.5,
backgroundColor: 'transparent',
justifyContent: 'center'
}}
thumbImage={require('../../img/sliderButton.png')}
value={this.logic.currentTime}
minimumValue={0}
maximumValue={this.state.videoDuration}
onValueChange={(currentTime) => { this.onSliderValueChanged(currentTime) }}
/>
</View>
</View>
</View>
)
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#000'
},
backWrap: {
height: '100%',
justifyContent: 'center',
paddingLeft: 30 / zoomW,
paddingRight: 30 / zoomW,
},
rightWrap: {
height: '100%',
justifyContent: 'center',
paddingLeft: 40 / zoomW,
paddingRight: 40 / zoomW,
},
imageWrap: {
flex: 1,
justifyContent: 'center',
alignItems: 'center'
},
controlWrap: {
width: '100%',
height: 157,
borderTopWidth: StyleSheet.hairlineWidth,
borderTopColor: 'rgba(255,255,255,.2)',
alignItems: 'center',
marginBottom:getFooterBottom(),
},
borderView: {
width: 126 / zoomW,
height: 70,
borderWidth: 2,
position: 'absolute',
top: -3
},
});