Watch: Update Back to LBRY button for Electron
This commit is contained in:
parent
471bf2fb10
commit
6059c3bebb
2 changed files with 50 additions and 13 deletions
|
@ -9,6 +9,10 @@ const VideoStream = require('videostream');
|
||||||
|
|
||||||
|
|
||||||
var WatchPage = React.createClass({
|
var WatchPage = React.createClass({
|
||||||
|
_isMounted: false,
|
||||||
|
_controlsHideDelay: 3000, // Note: this needs to be shorter than the built-in delay in Electron, or Electron will hide the controls before us
|
||||||
|
_controlsHideTimeout: null,
|
||||||
|
|
||||||
propTypes: {
|
propTypes: {
|
||||||
name: React.PropTypes.string,
|
name: React.PropTypes.string,
|
||||||
},
|
},
|
||||||
|
@ -18,6 +22,7 @@ var WatchPage = React.createClass({
|
||||||
readyToPlay: false,
|
readyToPlay: false,
|
||||||
loadStatusMessage: "Requesting stream",
|
loadStatusMessage: "Requesting stream",
|
||||||
mimeType: null,
|
mimeType: null,
|
||||||
|
controlsShown: false,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
componentDidMount: function() {
|
componentDidMount: function() {
|
||||||
|
@ -27,6 +32,37 @@ var WatchPage = React.createClass({
|
||||||
handleBackClicked: function() {
|
handleBackClicked: function() {
|
||||||
history.back();
|
history.back();
|
||||||
},
|
},
|
||||||
|
handleMouseMove: function() {
|
||||||
|
if (this._controlsTimeout) {
|
||||||
|
clearTimeout(this._controlsTimeout);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!this.state.controlsShown) {
|
||||||
|
this.setState({
|
||||||
|
controlsShown: true,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
this._controlsTimeout = setTimeout(() => {
|
||||||
|
if (!this.isMounted) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.setState({
|
||||||
|
controlsShown: false,
|
||||||
|
});
|
||||||
|
}, this._controlsHideDelay);
|
||||||
|
},
|
||||||
|
handleMouseOut: function() {
|
||||||
|
if (this._controlsTimeout) {
|
||||||
|
clearTimeout(this._controlsTimeout);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.state.controlsShown) {
|
||||||
|
this.setState({
|
||||||
|
controlsShown: false,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
updateLoadStatus: function() {
|
updateLoadStatus: function() {
|
||||||
lbry.getFileStatus(this.props.name, (status) => {
|
lbry.getFileStatus(this.props.name, (status) => {
|
||||||
if (!status || !['running', 'stopped'].includes(status.code) || status.written_bytes == 0) {
|
if (!status || !['running', 'stopped'].includes(status.code) || status.written_bytes == 0) {
|
||||||
|
@ -61,19 +97,22 @@ var WatchPage = React.createClass({
|
||||||
return (
|
return (
|
||||||
!this.state.readyToPlay
|
!this.state.readyToPlay
|
||||||
? <LoadScreen message={'Loading video...'} details={this.state.loadStatusMessage} />
|
? <LoadScreen message={'Loading video...'} details={this.state.loadStatusMessage} />
|
||||||
: <main className="video full-screen">
|
: <main className="video full-screen" onMouseMove={this.handleMouseMove} onMouseOut={this.handleMouseOut}>
|
||||||
<video width="100%" height="100%" id="video" ref="video" src={'/view?name=' + this.props.name} />
|
<video width="100%" height="100%" id="video" ref="video" src={'/view?name=' + this.props.name}
|
||||||
<div className="video__overlay">
|
controls={this.state.controlsShown}/>
|
||||||
<div className="video__back">
|
{this.state.controlsShown
|
||||||
<Link icon="icon-arrow-circle-o-left" className="video__back-link" onClick={this.handleBackClicked}/>
|
? <div className="video__overlay">
|
||||||
<div className="video__back-label">
|
<div className="video__back">
|
||||||
<Icon icon="icon-caret-left" className="video__back-label-arrow" />
|
<Link icon="icon-arrow-circle-o-left" className="video__back-link" onClick={this.handleBackClicked}/>
|
||||||
<div className="video__back-label-content">
|
<div className="video__back-label">
|
||||||
Back to LBRY
|
<Icon icon="icon-caret-left" className="video__back-label-arrow" />
|
||||||
|
<div className="video__back-label-content">
|
||||||
|
Back to LBRY
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
: null}
|
||||||
</div>
|
|
||||||
</main>
|
</main>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,9 +5,7 @@
|
||||||
.video__overlay {
|
.video__overlay {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 0px;
|
top: 0px;
|
||||||
bottom: 0px;
|
|
||||||
left: 0px;
|
left: 0px;
|
||||||
right: 0px;
|
|
||||||
color: #fff;
|
color: #fff;
|
||||||
z-index: 1;
|
z-index: 1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue