Skip to content
This repository has been archived by the owner on Jun 21, 2022. It is now read-only.

Commit

Permalink
Update video upload page
Browse files Browse the repository at this point in the history
  • Loading branch information
Yuki Ito committed Jan 19, 2016
1 parent 2fcdb0c commit e0ccd4a
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 4 deletions.
65 changes: 63 additions & 2 deletions src/components/video.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
import React from "react"; // eslint-disable-line
import { Component } from "flumpt";
import Anzu from "anzu-js-sdk";


export class VideoComponent extends Component {
constructor(props) {
super(props);
this.state = {
mouseOver: false,
};
}
componentDidUpdate() {
if (this.props.activeSourceId !== "") {
let constraints = {
Expand Down Expand Up @@ -29,9 +37,62 @@ export class VideoComponent extends Component {
);
}
}
handleVideoAction(e) {
e.preventDefault();
if (this.props.activeSourceId === "") {
return;
}
if (this.props.isPlaying) {
this.dispatch("stopAnzu");
return;
}
let constraints = {
audio: false,
video: {
mandatory: {
chromeMediaSource: "desktop",
chromeMediaSourceId: this.props.activeSourceId,
minWidth: 640,
maxWidth: 640,
minHeight: 480,
maxHeight: 480
}
}
};
const settings = JSON.parse(window.localStorage.getItem("decapSettings"));
let anzu = new Anzu("upstream");
anzu.start(settings.channelId, settings.upstreamToken, constraints);
this.dispatch("setAnzu", anzu);
}
handleMouseOver(_e) {
this.setState({ mouseOver: true });
}
handleMouseLeave(_e) {
this.setState({ mouseOver: false });
}
render() {
return(
<video id="video"></video>
let link = "";
if (this.state.mouseOver && this.props.activeSourceId !== "") {
if (this.props.isPlaying) {
link = (
<a className="video-button">
<span className="icon icon-resize-full icon-stop"></span>
</a>
);
}
else {
link = (
<a className="video-button">
<span className="icon icon-resize-full icon-play"></span>
</a>
);
}
}
return (
<div onMouseOver={this.handleMouseOver.bind(this)} onMouseLeave={this.handleMouseLeave.bind(this)} onClick={this.handleVideoAction.bind(this)}>
{ link }
<video id="video"></video>
</div>
);
}
}
14 changes: 12 additions & 2 deletions src/css/app.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
#video {
width: 640;
height: 480;
width: 640px;
height: 480px;
}
.video-button {
position: absolute;
top: 0;
left: 0;
width: 640px;
height: 480px;
font-size: 300px;
text-align: center;
color: rgba(255, 0, 0, 0.7);
}
8 changes: 8 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@ class Decap extends Flux {
return state;
});
});
this.on("stopAnzu", (anzu) => {
return this.update(state => {
state.anzu.disconnect();
state.anzu = null;
state.isPlaying = false;
return state;
});
});
this.on("updatePage", (page) => {
return this.update(state => {
state.page = page;
Expand Down

0 comments on commit e0ccd4a

Please sign in to comment.