@@ -184,9 +182,6 @@
-
-
2
-
);
}
diff --git a/src/VideoPlayer.js b/src/VideoPlayer.js
index e27ab78..b4f562f 100644
--- a/src/VideoPlayer.js
+++ b/src/VideoPlayer.js
@@ -7,15 +7,6 @@ class VideoPlayer extends Component {
constructor(props) {
super(props);
this.state = {
- opt: {
- // height: '390',
- // width: '640',
- playerVars: {
- // https://developers.google.com/youtube/player_parameters
- autoplay: 0,
- modestbranding: 1
- }
- },
videoId: '0J2QdDbelmY',
promise1: null,
promise2: null,
@@ -33,6 +24,7 @@ class VideoPlayer extends Component {
return { videoId: props.match.params.id };
});
}
+
}
componentWillReceiveProps(nextProps) {
@@ -44,24 +36,36 @@ class VideoPlayer extends Component {
this.setState((state, props) => {
return { videoId: props.match.params.id };
});
+
}
componentWillUnmount() {}
render() {
+ const opts= {
+ height: '520',
+ width: '900',
+ playerVars: {
+ // https://developers.google.com/youtube/player_parameters
+ autoplay: 0,
+ modestbranding: 1
+ }
+ };
return (
+
+
);
}
@@ -74,6 +78,7 @@ class VideoPlayer extends Component {
_onReady(event) {}
+
_onStateChange(event) {
let timerId1, timerId2;
if (parseInt(event.data) === -1) {
diff --git a/src/reccomenders/Related.js b/src/reccomenders/Related.js
index f031881..2a2e085 100644
--- a/src/reccomenders/Related.js
+++ b/src/reccomenders/Related.js
@@ -1,45 +1,97 @@
import React, { Component } from 'react';
import PropTypes from 'prop-types';
+import axios from 'axios';
+import YouTube from "react-youtube";
+import {Link} from "react-router-dom";
+import {Card} from "react-bootstrap";
+import CardGroup from "react-bootstrap/es/CardGroup";
class Related extends Component {
constructor(props) {
super(props);
-
+ this.state={
+ videoId : '0J2QdDbelmY',
+ items : []
+ }
}
componentWillMount() {
-
+ if(this.props.match.params.id){
+ if(this.props.match.params.id === this.state.videoId){}
+ else{
+ this.setState({videoId: this.props.match.params.id});
+ }
+ }
}
componentDidMount() {
-
+ axios.get("https://www.googleapis.com/youtube/v3/search",{
+ params:{
+ 'part': 'snippet',
+ 'relatedToVideoId' : this.state.videoId,
+ 'type' : 'video',
+ 'maxResults' : '21',
+ 'key': 'AIzaSyA21Odw9UdfiOJnxvA_eDfOW0OxuUfHKig'
+ }
+ }).then(
+ response => {
+ this.setState({
+ items: response.data.items,
+ })
+ console.log(response);
+ },
+ error => {
+ console.error(error);
+ }
+ )
}
- componentWillReceiveProps(nextProps) {
+ //componentWillReceiveProps(nextProps) {}
- }
-
- shouldComponentUpdate(nextProps, nextState) {
-
- }
+ //shouldComponentUpdate(nextProps, nextState) {}
componentWillUpdate(nextProps, nextState) {
-
+ if(nextProps.match.params.id === this.state.videoId){}
+ else if( nextProps.match.params.id){
+ this.setState({videoId: nextProps.match.params.id});
+ }
}
- componentDidUpdate(prevProps, prevState) {
+ //componentDidUpdate(prevProps, prevState) {}
- }
-
- componentWillUnmount() {
-
- }
+ //componentWillUnmount() {}
render() {
return (
-
-
-
+
+ {this.state.items.map(function (item,index) {
+ return(
+
+
+
+
+
+
+ {item.snippet.title}
+ {item.snippet.channelTitle} - {item.snippet.publishedAt.replace(/(\d+)-(\d+)-(\d+)T(\d+):(\d+):(\d+).000Z/,function(match,p1,p2,p3,p4,p5,p6){
+ return(p3+'/'+p2+'/'+p1+' at '+p4+':'+p5+':'+p6); //Funzione che trasforma la data e ora di pubblicazione dal formato ISO nel normale formato da cristiani
+ })}
+
+
+
+
+
+ )
+ })}
+
);
}
}