import { h, Component } from 'preact' import { bindActionCreators } from 'redux' import { connect } from 'react-redux' import Player from '../common/player.component' import ParamGroup from '../common/paramGroup.component' import Slider from '../common/slider.component' import Select from '../common/select.component' import Button from '../common/button.component' import { startRecording, stopRecording, saveFrame } from '../live/player' import * as liveActions from '../live/actions' class LivePix2Pix extends Component { constructor(props){ super() props.actions.get_params() props.actions.list_checkpoints() props.actions.list_sequences() this.changeCheckpoint = this.changeCheckpoint.bind(this) this.changeEpoch = this.changeEpoch.bind(this) this.changeSequence = this.changeSequence.bind(this) this.seek = this.seek.bind(this) this.togglePlaying = this.togglePlaying.bind(this) this.toggleRecording = this.toggleRecording.bind(this) } componentWillUpdate(nextProps) { if (nextProps.opt.checkpoint_name && nextProps.opt.checkpoint_name !== this.props.opt.checkpoint_name) { this.props.actions.list_epochs(nextProps.opt.checkpoint_name) } } changeCheckpoint(checkpoint_name){ this.props.actions.load_epoch(checkpoint_name, 'latest') } changeEpoch(epoch_name){ this.props.actions.load_epoch(this.props.opt.checkpoint_name, epoch_name) } changeSequence(sequence){ console.log('got sequence', sequence) this.props.actions.load_sequence(sequence) } seek(percentage){ const frame = Math.floor(percentage * (parseInt(this.props.frame.sequence_len) || 1) + 1) this.props.actions.seek(frame) } togglePlaying(){ if (this.props.opt.processing) { this.props.actions.pause() } else { this.props.actions.play() } } toggleRecording(){ if (this.props.opt.recording){ stopRecording() this.props.actions.pause() } else { startRecording() } } render(){ return (