OpenMediaCenter/src/Preview.js

62 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 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}
2020-06-01 18:46:28 +00:00
alt='Pic loading.'/>
2020-05-31 18:24:35 +00:00
</div>
</div>
);
}
itemClick() {
console.log("item clicked!" + this.state.name);
2020-06-01 18:46:28 +00:00
this.props.viewbinding.showVideo(<Player
viewbinding={this.props.viewbinding}
movie_id={this.props.movie_id}/>);
}
2020-05-31 18:24:35 +00:00
}
export default Preview;