2020-10-25 18:48:23 +00:00
|
|
|
import React from 'react';
|
|
|
|
import style from './Preview.module.css';
|
|
|
|
import Player from '../../pages/Player/Player';
|
|
|
|
import {Spinner} from 'react-bootstrap';
|
2020-12-17 20:53:22 +00:00
|
|
|
import GlobalInfos from '../../utils/GlobalInfos';
|
|
|
|
import {callAPIPlain} from '../../utils/Api';
|
2020-05-31 20:24:35 +02:00
|
|
|
|
2020-08-12 17:50:25 +00:00
|
|
|
/**
|
|
|
|
* Component for single preview tile
|
|
|
|
* floating side by side
|
|
|
|
*/
|
2020-05-31 20:24:35 +02:00
|
|
|
class Preview extends React.Component {
|
|
|
|
constructor(props, context) {
|
|
|
|
super(props, context);
|
|
|
|
|
|
|
|
this.state = {
|
|
|
|
previewpicture: null,
|
2020-05-31 23:22:50 +02:00
|
|
|
name: null
|
2020-05-31 20:24:35 +02:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
componentDidMount() {
|
2020-12-17 20:53:22 +00:00
|
|
|
callAPIPlain('video.php', {action: 'readThumbnail', movieid: this.props.movie_id}, (result) => {
|
|
|
|
this.setState({
|
|
|
|
previewpicture: result,
|
|
|
|
name: this.props.name
|
|
|
|
});
|
2020-05-31 23:22:50 +02:00
|
|
|
});
|
2020-05-31 20:24:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
2020-08-05 22:00:55 +02:00
|
|
|
const themeStyle = GlobalInfos.getThemeStyle();
|
2020-05-31 20:24:35 +02:00
|
|
|
return (
|
2020-10-09 14:00:51 +00:00
|
|
|
<div className={style.videopreview + ' ' + themeStyle.secbackground + ' ' + themeStyle.preview}
|
|
|
|
onClick={() => this.itemClick()}>
|
2020-08-12 17:50:25 +00:00
|
|
|
<div className={style.previewtitle + ' ' + themeStyle.lighttextcolor}>{this.state.name}</div>
|
2020-07-08 00:14:08 +02:00
|
|
|
<div className={style.previewpic}>
|
2020-08-05 17:55:51 +00:00
|
|
|
{this.state.previewpicture !== null ?
|
2020-07-08 00:14:08 +02:00
|
|
|
<img className={style.previewimage}
|
2020-06-18 21:53:48 +02:00
|
|
|
src={this.state.previewpicture}
|
|
|
|
alt='Pic loading.'/> :
|
2020-10-19 21:12:07 +00:00
|
|
|
<span className={style.loadAnimation}><Spinner animation='border'/></span>}
|
2020-06-18 21:53:48 +02:00
|
|
|
|
2020-05-31 20:24:35 +02:00
|
|
|
</div>
|
2020-07-08 00:14:08 +02:00
|
|
|
<div className={style.previewbottom}>
|
2020-06-04 16:45:24 +02:00
|
|
|
|
|
|
|
</div>
|
2020-05-31 20:24:35 +02:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
2020-05-31 23:22:50 +02:00
|
|
|
|
2020-08-12 17:50:25 +00:00
|
|
|
/**
|
|
|
|
* handle the click event of a tile
|
|
|
|
*/
|
2020-05-31 23:22:50 +02:00
|
|
|
itemClick() {
|
2020-10-25 18:48:23 +00:00
|
|
|
console.log('item clicked!' + this.state.name);
|
2020-05-31 23:22:50 +02:00
|
|
|
|
2020-12-11 18:23:13 +00:00
|
|
|
GlobalInfos.getViewBinding().changeRootElement(
|
|
|
|
<Player movie_id={this.props.movie_id}/>);
|
2020-05-31 23:22:50 +02:00
|
|
|
}
|
2020-05-31 20:24:35 +02:00
|
|
|
}
|
|
|
|
|
2020-08-12 17:50:25 +00:00
|
|
|
/**
|
|
|
|
* Component for a Tag-name tile (used in category page)
|
|
|
|
*/
|
2020-06-07 15:48:27 +02:00
|
|
|
export class TagPreview extends React.Component {
|
|
|
|
render() {
|
2020-08-05 22:00:55 +02:00
|
|
|
const themeStyle = GlobalInfos.getThemeStyle();
|
2020-06-07 15:48:27 +02:00
|
|
|
return (
|
2020-10-09 14:00:51 +00:00
|
|
|
<div
|
|
|
|
className={style.videopreview + ' ' + style.tagpreview + ' ' + themeStyle.secbackground + ' ' + themeStyle.preview}
|
|
|
|
onClick={() => this.itemClick()}>
|
2020-08-03 23:31:43 +00:00
|
|
|
<div className={style.tagpreviewtitle + ' ' + themeStyle.lighttextcolor}>
|
2020-06-07 21:42:01 +02:00
|
|
|
{this.props.name}
|
2020-06-07 15:48:27 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2020-08-12 17:50:25 +00:00
|
|
|
/**
|
|
|
|
* handle the click event of a Tag tile
|
|
|
|
*/
|
2020-06-07 21:42:01 +02:00
|
|
|
itemClick() {
|
2020-06-24 21:47:22 +02:00
|
|
|
this.props.categorybinding(this.props.name);
|
2020-06-07 15:48:27 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-31 20:24:35 +02:00
|
|
|
export default Preview;
|