aboutsummaryrefslogtreecommitdiffstats
path: root/apps/Player/components/Video.js
diff options
context:
space:
mode:
Diffstat (limited to 'apps/Player/components/Video.js')
-rw-r--r--apps/Player/components/Video.js38
1 files changed, 35 insertions, 3 deletions
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.
</video>
- {audioOnly && (
+ {(audioOnly || playlist[current].type === 'radio') && (
<>
<div />
<span style={{ backgroundImage: `url(${data.thumbnail})` }} />