From f8463676a40656893c2048655e8807099e3adb39 Mon Sep 17 00:00:00 2001 From: piotrruss Date: Mon, 10 Apr 2023 21:57:33 +0200 Subject: add radio app --- apps/Player/components/Video.js | 38 +++++++++++++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 3 deletions(-) (limited to 'apps/Player/components/Video.js') diff --git a/apps/Player/components/Video.js b/apps/Player/components/Video.js index de00761..2167ee0 100644 --- a/apps/Player/components/Video.js +++ b/apps/Player/components/Video.js @@ -1,9 +1,13 @@ import { useState, useEffect, useRef } from 'react' import Image from 'next/image' import Splash from 'components/Splash' +import usePopup from 'hooks/usePopup' +import useSettings from 'hooks/useSettings' import fetchJson from 'helpers/fetchJson' const Video = ({ playlist, current, setCurrent, audioOnly = false, setDetails }) => { + const { t } = useSettings() + const { setPopup } = usePopup() const [data, setData] = useState(null) const [loading, setLoading] = useState(null) const videoEl = useRef() @@ -40,9 +44,37 @@ const Video = ({ playlist, current, setCurrent, audioOnly = false, setDetails }) description: v.videoDetails.description })) }) - .catch(() => console.log('error fetching video')) + .catch(() => { + setData({ + // thumbnail: v.videoDetails.thumbnails[0].url, + formats: [] + }) + setDetails(d => ({ + ...d, + title: 'Error', + description: 'Item did not load correctly' + })) + setPopup({ + content: t('player_youtube_fetching_error'), + time: 2000, + error: true + }) + }) .finally(() => setLoading(false)) - break + break + case 'radio': + const { url, mimeType, thumbnail, title } = playlist[current]; + setData({ + thumbnail, + formats: [{ url, mimeType }] + }) + setDetails(d => ({ + ...d, + title: 'Gra radio ' + title, + description: '' + })) + setLoading(false) + break default: } }, [playlist && playlist[current].id, audioOnly]) @@ -67,7 +99,7 @@ const Video = ({ playlist, current, setCurrent, audioOnly = false, setDetails }) } Your browser does not support the video tag. - {audioOnly && ( + {(audioOnly || playlist[current].type === 'radio') && ( <>
-- cgit v1.2.3