Skip to content

Commit

Permalink
Youtube plays a random video
Browse files Browse the repository at this point in the history
  • Loading branch information
doguscan committed Dec 20, 2017
1 parent 9296409 commit 7f7896e
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ class App extends Component {
this._onEnd = this._onEnd.bind(this);
this._onPause = this._onPause.bind(this);
this.incrementIndex = this.incrementIndex.bind(this);
this._onYoutubePlayerClicked = this._onYoutubePlayerClicked.bind(this);
this._onReady = this._onReady.bind(this);
}

Expand Down Expand Up @@ -74,15 +73,13 @@ class App extends Component {
});
}

_onYoutubePlayerClicked() {
let index = this.state.index;
if ((index + 1) === this.state.data.length) index = -1;
this.setState({index: index + 1, wtfCount: this.state.data[index + 1].wtfCount});
}

_onReady() {
console.log("_onReady");
this.setState({videoMode: true})
const index = this.state.index;
const length = this.state.data.length;
let randomIndex = Math.floor(Math.random() * length);

this.setState({videoMode: true, index: randomIndex})
}

openingContent = () => {
Expand All @@ -91,7 +88,6 @@ class App extends Component {
)
}


render() {
let data = this.state.data[this.state.index] ? this.state.data[this.state.index] : undefined;
return (
Expand Down

0 comments on commit 7f7896e

Please sign in to comment.