From 081d9f5207fc99e084164d78294ad7e05b7f7220 Mon Sep 17 00:00:00 2001 From: Vu Anh Date: Sun, 6 Oct 2024 04:09:46 +0000 Subject: [PATCH] update --- apps/languagesv2/languages-v2-web/src/App.tsx | 5 +- .../languages-v2-web/src/pages/Home.tsx | 25 +++- .../languages-v2-web/src/pages/Video.tsx | 111 ++++++++++++++++++ 3 files changed, 135 insertions(+), 6 deletions(-) create mode 100644 apps/languagesv2/languages-v2-web/src/pages/Video.tsx diff --git a/apps/languagesv2/languages-v2-web/src/App.tsx b/apps/languagesv2/languages-v2-web/src/App.tsx index 9c871a02..91e07765 100644 --- a/apps/languagesv2/languages-v2-web/src/App.tsx +++ b/apps/languagesv2/languages-v2-web/src/App.tsx @@ -2,8 +2,10 @@ import React from 'react'; import './App.css'; import { BrowserRouter as Router, Route, Routes } from 'react-router-dom'; import Home from './pages/Home'; -import Quiz from './pages/Quiz'; import Nav from './pages/Nav'; +import Quiz from './pages/Quiz'; +import Video from './pages/Video'; + function App() { return ( @@ -14,6 +16,7 @@ function App() { } /> } /> + } /> diff --git a/apps/languagesv2/languages-v2-web/src/pages/Home.tsx b/apps/languagesv2/languages-v2-web/src/pages/Home.tsx index 00c5e351..b0438b24 100644 --- a/apps/languagesv2/languages-v2-web/src/pages/Home.tsx +++ b/apps/languagesv2/languages-v2-web/src/pages/Home.tsx @@ -3,7 +3,7 @@ import { Link } from 'react-router-dom'; function Home() { return ( -
+
{/* Header Section */}

Languages

@@ -14,12 +14,17 @@ function Home() {

English πŸ‡¬πŸ‡§

Master English with our engaging quizzes and exercises. Unlock the full potential of your language skills and take your communication to the next level!

-
+
πŸš€ Start Your English Adventure Now! + + πŸŽ₯ Watch English Videos +
@@ -27,12 +32,17 @@ function Home() {

Vietnamese πŸ‡»πŸ‡³

Discover the beauty of the Vietnamese language through fun and immersive quizzes. Let’s explore the culture and language together!

-
+
🌟 Start Vietnamese Quiz and Uncover the Magic! + + πŸŽ₯ Watch Vietnamese Videos +
@@ -40,17 +50,22 @@ function Home() {

Chinese πŸ‡¨πŸ‡³

Begin your Mandarin Chinese journey with fun, engaging quizzes. Unlock the wonders of the Chinese language and culture!

-
+
πŸ‰ Start Chinese Quiz and Begin Your Journey! + + πŸŽ₯ Watch Chinese Videos +
{/* Footer Section */} -
+

Happy learning! Stay consistent, stay curious. πŸš€ Let every quiz be a new adventure!

diff --git a/apps/languagesv2/languages-v2-web/src/pages/Video.tsx b/apps/languagesv2/languages-v2-web/src/pages/Video.tsx new file mode 100644 index 00000000..9216748c --- /dev/null +++ b/apps/languagesv2/languages-v2-web/src/pages/Video.tsx @@ -0,0 +1,111 @@ +import React, { useState, useRef } from 'react'; +import { useParams } from 'react-router-dom'; + +type VideoData = { + [key: string]: { title: string; url: string }[]; +}; + +function Video() { + const { language } = useParams<{ language: string }>(); + const [currentIndex, setCurrentIndex] = useState(0); + const videoRef = useRef(null); + + const videoData: VideoData = { + English: [ + { + title: 'Gotye - Somebody That I Used To Know (feat. Kimbra)', + url: 'https://www.youtube.com/embed/8UVNT4wvIGY?si=0ZDLyY8p4nvbSpaB&controls=0', + }, + { + title: 'MPOSSIBLE! [or NOT?] – Learn English Conversation in 4 Hours', + url: 'https://www.youtube.com/embed/8FzY7cgKOmI?si=uADlutuyhPhXBkSc&controls=0', + }, + ], + Vietnamese: [ + { + title: 'Vietnamese Phrases You Need at the Station', + url: 'https://www.youtube.com/embed/0E50Kk0DNJk?si=U3dGZ77CUHb9VPoJ&controls=0', + }, + { + title: 'Learn Vietnamese in 2 Hours - Beginners Guide', + url: 'https://www.youtube.com/embed/UvmzrMWD8_Y?si=e-DJH7gp00bS0yjZ&controls=0', + }, + ], + Chinese: [ + { + title: '340 Chinese Words You\'ll Use Every Day - Basic Vocabulary #74', + url: 'https://www.youtube.com/embed/40UHvFIJU6U?si=71k8LZKXJmu5oJAO&controls=0', + }, + { + title: 'Listening Practice - Naming Culture in China', + url: 'https://www.youtube.com/embed/BCqjc388ExM?si=WDi8obbQM_fPEC22&controls=0', + }, + ], + }; + + const handlePlay = () => { + if (videoRef.current) { + const iframeWindow = videoRef.current.contentWindow; + iframeWindow?.postMessage('{"event":"command","func":"playVideo","args":""}', '*'); + } + }; + + const handlePause = () => { + if (videoRef.current) { + const iframeWindow = videoRef.current.contentWindow; + iframeWindow?.postMessage('{"event":"command","func":"pauseVideo","args":""}', '*'); + } + }; + + const handleNext = () => { + setCurrentIndex((prevIndex) => (prevIndex + 1) % videoData[language as string].length); + }; + + const currentVideo = videoData[language as string]?.[currentIndex]; + + return ( +
+ {/* Video Section */} + {currentVideo && ( +
+
+

{currentVideo.title}

+
+ +
+
+ + + +
+
+
+ )} +
+ ); +} + +export default Video; \ No newline at end of file