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

78 lines
1.9 KiB
JavaScript
Raw Normal View History

2022-10-07 16:41:43 +02:00
import React from 'react';
import { Dimensions, View } 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';
// Sentry
import * as Sentry from '@sentry/react-native';
2022-10-07 16:41:43 +02:00
2022-12-30 10:02:07 +01:00
function mapStateToProps(state) {
return {
mainColor: state.app.mainColor,
};
2022-12-30 10:02:07 +01:00
}
2022-10-07 16:41:43 +02:00
class VideoScreen extends React.Component {
render() {
const { uuid } = this.props.route.params;
let width = Dimensions.get('window').width;
let height = Dimensions.get('window').height;
2022-12-29 15:25:30 +01:00
// * If on portrait
if (height > width) {
const tmpHeight = height;
height = width - 150;
width = tmpHeight + 100;
} else {
height = height - 100;
2022-10-07 16:41:43 +02:00
}
const videoUri = `${FileSystem.documentDirectory}${uuid}.mp4`;
console.debug({
shouldPlay: true,
resizeMode: ResizeMode.CONTAIN,
source: {
uri: videoUri,
},
});
try {
return (
<View style={{ flex: 1, backgroundColor: 'black' }}>
<VideoPlayer
defaultControlsVisible={true}
fullscreen={{
visible: false,
}}
slider={{
minimumTrackTintColor: this.props.mainColor,
thumbTintColor: this.props.mainColor,
}}
style={{
height: height,
width: width,
}}
videoProps={{
shouldPlay: true,
resizeMode: ResizeMode.CONTAIN,
source: {
uri: videoUri,
},
}}
errorCallback={e => {
console.error(e);
2023-09-05 09:27:14 +02:00
Sentry.captureException(e);
}}
/>
</View>
);
} catch (e) {
console.error(e);
}
}
2022-10-07 16:41:43 +02:00
}
export default connect(mapStateToProps)(VideoScreen);