OpenMediaCenter/src/Preview.js

61 lines
1.6 KiB
JavaScript
Raw Normal View History

2020-05-31 18:24:35 +00:00
import React from "react";
import "./css/Preview.css"
import ReactDOM from "react-dom";
import Player from "./Player";
2020-05-31 18:24:35 +00:00
class Preview extends React.Component {
constructor(props, context) {
super(props, context);
this.props = props;
this.state = {
previewpicture: null,
name: null
2020-05-31 18:24:35 +00:00
};
}
componentWillUnmount() {
this.setState({});
}
componentDidMount() {
this.setState({
previewpicture: null,
name: this.props.name
});
2020-05-31 18:24:35 +00:00
const updateRequest = new FormData();
updateRequest.append('action', 'readThumbnail');
updateRequest.append('movieid', this.props.movie_id);
fetch('/php/videoload.php', {method: 'POST', body: updateRequest})
.then((response) => response.text())
.then((result) => {
this.setState(prevState => ({
...prevState.previewpicture, previewpicture: result
}));
});
}
render() {
return (
<div className='videopreview' onClick={() => this.itemClick()}>
2020-05-31 18:24:35 +00:00
<div className='previewtitle'>{this.state.name}</div>
<div className='previewpic'>
<img className='previewimage'
src={this.state.previewpicture}
alt='no thumbnail found'/>
</div>
</div>
);
}
itemClick() {
console.log("item clicked!"+this.state.name);
this.props.showvideo(<Player movie_id={this.props.movie_id}/>);
}
2020-05-31 18:24:35 +00:00
}
export default Preview;