ldc-com-app/ComApp/src/App/Views/VideoScreen.js

59 lines
1.7 KiB
JavaScript
Raw Normal View History

2022-10-07 16:41:43 +02:00
import React from 'react';
import { View, Dimensions } from 'react-native';
2022-12-30 10:02:07 +01:00
// Reduxs
import { connect } from 'react-redux';
2022-10-07 16:41:43 +02:00
// FileSytem
import * as FileSystem from 'expo-file-system';
// Video
2022-12-29 15:25:30 +01:00
import { ResizeMode } from 'expo-av';
2022-10-07 16:41:43 +02:00
import VideoPlayer from 'expo-video-player';
2022-12-30 10:02:07 +01:00
function mapStateToProps(state) {
return {
mainColor: state.app.mainColor
};
}
2022-10-07 16:41:43 +02:00
class VideoScreen extends React.Component {
render() {
const { uuid } = this.props.route.params;
2022-12-29 15:25:30 +01:00
let width = Dimensions.get("window").width;
let height = Dimensions.get("window").height;
// if portrait
if (height > width) {
let tmpHeight = height;
height = width - 150;
width = tmpHeight + 100;
} else {
height = height - 100;
}
2022-10-07 16:41:43 +02:00
return (
2022-12-29 15:25:30 +01:00
<View style={{ flex: 1, backgroundColor: 'black' }}>
2022-10-07 16:41:43 +02:00
<VideoPlayer
2022-12-29 15:25:30 +01:00
defaultControlsVisible={true}
fullscreen={{
visible: false
}}
slider={{
2022-12-30 10:02:07 +01:00
minimumTrackTintColor: this.props.mainColor,
thumbTintColor: this.props.mainColor,
2022-12-29 15:25:30 +01:00
}}
style={{
height: height,
width: width
}}
2022-10-07 16:41:43 +02:00
videoProps={{
shouldPlay: true,
2022-12-29 15:25:30 +01:00
resizeMode: ResizeMode.CONTAIN,
2022-10-07 16:41:43 +02:00
source: {
uri: FileSystem.documentDirectory + uuid + '.mp4',
},
}}
/>
</View>
);
}
}
2022-12-30 10:02:07 +01:00
export default connect(mapStateToProps)(VideoScreen);