2020-05-31 20:24:35 +02:00
|
|
|
import React from "react";
|
2020-06-12 15:57:30 +00:00
|
|
|
import "./Preview.css";
|
|
|
|
import Player from "../../pages/Player/Player";
|
|
|
|
import VideoContainer from "../VideoContainer/VideoContainer";
|
2020-06-18 21:53:48 +02:00
|
|
|
import {Spinner} from "react-bootstrap";
|
2020-05-31 20:24:35 +02:00
|
|
|
|
|
|
|
class Preview extends React.Component {
|
|
|
|
constructor(props, context) {
|
|
|
|
super(props, context);
|
|
|
|
this.props = props;
|
|
|
|
|
|
|
|
this.state = {
|
|
|
|
previewpicture: null,
|
2020-05-31 23:22:50 +02:00
|
|
|
name: null
|
2020-05-31 20:24:35 +02:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
componentWillUnmount() {
|
|
|
|
this.setState({});
|
|
|
|
}
|
|
|
|
|
|
|
|
componentDidMount() {
|
|
|
|
this.setState({
|
|
|
|
previewpicture: null,
|
2020-05-31 23:22:50 +02:00
|
|
|
name: this.props.name
|
|
|
|
});
|
2020-05-31 20:24:35 +02:00
|
|
|
|
|
|
|
const updateRequest = new FormData();
|
|
|
|
updateRequest.append('action', 'readThumbnail');
|
|
|
|
updateRequest.append('movieid', this.props.movie_id);
|
|
|
|
|
2020-06-01 21:36:55 +02:00
|
|
|
fetch('/api/videoload.php', {method: 'POST', body: updateRequest})
|
2020-06-12 15:57:30 +00:00
|
|
|
.then((response) => response.text()
|
|
|
|
.then((result) => {
|
|
|
|
this.setState(prevState => ({
|
|
|
|
...prevState.previewpicture, previewpicture: result
|
|
|
|
}));
|
2020-05-31 20:24:35 +02:00
|
|
|
}));
|
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
|
|
|
return (
|
2020-05-31 23:22:50 +02:00
|
|
|
<div className='videopreview' onClick={() => this.itemClick()}>
|
2020-06-12 15:57:30 +00:00
|
|
|
<div className='previewtitle'>{this.state.name}</div>
|
2020-05-31 20:24:35 +02:00
|
|
|
<div className='previewpic'>
|
2020-06-18 21:53:48 +02:00
|
|
|
{this.state.previewpicture != null ?
|
|
|
|
<img className='previewimage'
|
|
|
|
src={this.state.previewpicture}
|
|
|
|
alt='Pic loading.'/> :
|
|
|
|
<span className='loadAnimation'><Spinner animation="border"/></span>}
|
|
|
|
|
2020-05-31 20:24:35 +02:00
|
|
|
</div>
|
2020-06-04 16:45:24 +02:00
|
|
|
<div className='previewbottom'>
|
|
|
|
|
|
|
|
</div>
|
2020-05-31 20:24:35 +02:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
2020-05-31 23:22:50 +02:00
|
|
|
|
|
|
|
itemClick() {
|
2020-06-01 19:09:32 +02:00
|
|
|
console.log("item clicked!" + this.state.name);
|
2020-05-31 23:22:50 +02:00
|
|
|
|
2020-06-21 23:08:46 +02:00
|
|
|
this.props.viewbinding.changeRootElement(
|
|
|
|
<Player
|
|
|
|
viewbinding={this.props.viewbinding}
|
|
|
|
movie_id={this.props.movie_id}/>);
|
2020-05-31 23:22:50 +02:00
|
|
|
}
|
2020-05-31 20:24:35 +02:00
|
|
|
}
|
|
|
|
|
2020-06-07 15:48:27 +02:00
|
|
|
export class TagPreview extends React.Component {
|
2020-06-07 22:17:55 +02:00
|
|
|
constructor(props, context) {
|
2020-06-07 15:48:27 +02:00
|
|
|
super(props, context);
|
|
|
|
|
|
|
|
this.props = props;
|
|
|
|
}
|
|
|
|
|
2020-06-07 21:42:01 +02:00
|
|
|
fetchVideoData(tag) {
|
|
|
|
console.log(tag);
|
|
|
|
const updateRequest = new FormData();
|
|
|
|
updateRequest.append('action', 'getMovies');
|
|
|
|
updateRequest.append('tag', tag);
|
|
|
|
|
|
|
|
console.log("fetching data");
|
|
|
|
|
|
|
|
// fetch all videos available
|
|
|
|
fetch('/api/videoload.php', {method: 'POST', body: updateRequest})
|
|
|
|
.then((response) => response.json()
|
|
|
|
.then((result) => {
|
|
|
|
console.log(result);
|
2020-06-07 22:17:55 +02:00
|
|
|
this.props.categorybinding(
|
2020-06-07 21:42:01 +02:00
|
|
|
<VideoContainer
|
|
|
|
data={result}
|
2020-06-12 15:57:30 +00:00
|
|
|
viewbinding={this.props.viewbinding}/>, tag
|
2020-06-07 21:42:01 +02:00
|
|
|
);
|
|
|
|
}))
|
|
|
|
.catch(() => {
|
|
|
|
console.log("no connection to backend");
|
|
|
|
});
|
2020-06-07 15:48:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
render() {
|
|
|
|
return (
|
2020-06-07 21:42:01 +02:00
|
|
|
<div className='videopreview tagpreview' onClick={() => this.itemClick()}>
|
|
|
|
<div className='tagpreviewtitle'>
|
|
|
|
{this.props.name}
|
2020-06-07 15:48:27 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2020-06-07 21:42:01 +02:00
|
|
|
itemClick() {
|
|
|
|
this.fetchVideoData(this.props.name);
|
2020-06-07 15:48:27 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-31 20:24:35 +02:00
|
|
|
export default Preview;
|