@@ -3,7 +3,7 @@ import { useParams } from 'react-router-dom';
33import axios from 'axios' ;
44import config from '../config' ;
55import { Redirect } from 'react-router-dom' ;
6- import PlayQuestion from './PlayQuestion' ;
6+ import ReactPlayer from 'react-player'
77import './css/play.css' ;
88
99export default function Play ( ) {
@@ -30,6 +30,7 @@ export default function Play(){
3030 }
3131 } ) ;
3232 }
33+
3334 async function fetchQuestions ( ) {
3435 await axios . get ( `http://${ config . server } /quizzes/${ id_quizz } /questions` )
3536 . then ( res => {
@@ -45,6 +46,23 @@ export default function Play(){
4546 } ) ;
4647 }
4748
49+ function playQuestion ( question ) {
50+ return (
51+ < div id = 'question' >
52+ { question . path_file !== '' ?
53+ < ReactPlayer
54+ id = 'player'
55+ controls = { true }
56+ volume = { 0.5 }
57+ wrapper = 'question'
58+ url = { `http://${ config . server } /video/${ question . path_file } ` }
59+ />
60+ : '' }
61+ < h2 > { question . question } </ h2 >
62+ </ div >
63+ ) ;
64+ }
65+
4866 useEffect ( ( ) => {
4967 fetchQuizz ( ) ;
5068 fetchQuestions ( ) ;
@@ -81,13 +99,13 @@ export default function Play(){
8199 }
82100 }
83101
84- function handleNext ( ) {
102+ function handleNext ( ) {
85103 for ( const i of document . querySelectorAll ( '.material-icons' ) ) {
86104 i . style . visibility = 'hidden' ;
87105 }
88106 document . querySelector ( '#next-button' ) . style . visibility = 'hidden' ;
89107 setCurrentidx ( parseInt ( currentidx ) + 1 ) ;
90- setAnswered ( false ) ;
108+ setAnswered ( false ) ;
91109 }
92110
93111 return (
@@ -99,17 +117,19 @@ export default function Play(){
99117 < h2 > { quizz ? quizz . title : "Quizz not found" } </ h2 >
100118 </ div >
101119
102- { currentQuestion ? < PlayQuestion question = { currentQuestion . question } src = { currentQuestion . path_file } /> : '' }
120+ { currentQuestion ? playQuestion ( currentQuestion ) : '' }
103121
104122 < div id = 'score' >
105123 < h2 > Score : { score ? score : 0 } </ h2 >
106124 </ div >
125+
126+ < div id = 'chrono' >
127+ </ div >
107128
108129 < div id = 'answers' >
109130 { currentAnswers ?
110131 currentAnswers . map ( ( a , idx ) => {
111132 if ( a . path_file . split ( '.' ) [ 1 ] !== 'jpg' ) {
112- console . log ( 'pas image' )
113133 return (
114134 < div className = 'answer'
115135 id = { 'answer' + idx }
0 commit comments