Add Gade integration

This commit is contained in:
2023-03-07 08:56:53 +04:00
parent 814d07370b
commit 27952581af
+35 -6
View File
@@ -7,7 +7,8 @@ import {
Spotify, Spotify,
Deezer, Deezer,
Soundcloud, Soundcloud,
Applemusic Applemusic,
Peertube
} from '@icons-pack/react-simple-icons' } from '@icons-pack/react-simple-icons'
import {useEffect, useState} from 'react' import {useEffect, useState} from 'react'
@@ -19,7 +20,7 @@ const kouteyAchteyIcons = {
Applemusic: <Applemusic /> Applemusic: <Applemusic />
} }
function RannIframe({plateforme, url, isMobile}) { function RannIframe({plateforme, url, titre, isMobile}) {
let src = '' let src = ''
switch (plateforme) { switch (plateforme) {
case 'Tidal': { case 'Tidal': {
@@ -73,6 +74,18 @@ function RannIframe({plateforme, url, isMobile}) {
/> />
)} )}
{plateforme === 'Gade' && (
<iframe
src={`${url}?subtitle=fr&amp;warningTitle=0&amp;peertubeLink=0`}
allowFullScreen='allowfullscreen'
title={titre}
frameBorder='0'
height={isMobile ? '' : '315'}
width={isMobile ? '' : '560'}
sandbox='allow-same-origin allow-scripts allow-popups'
/>
)}
{plateforme === 'Deezer' && ( {plateforme === 'Deezer' && (
<iframe <iframe
title='deezer-widget' title='deezer-widget'
@@ -122,15 +135,16 @@ function RannIframe({plateforme, url, isMobile}) {
function EntegreMizik({parole, isMobile}) { function EntegreMizik({parole, isMobile}) {
const [chwaMizik, meteChwaMizik] = useState(null) const [chwaMizik, meteChwaMizik] = useState(null)
const router = useRouter() const router = useRouter()
const {streamAudio, slug, okiMizikID} = parole const {streamAudio, slug, okiMizikID, gadeEmbed, titre} = parole
const filteredKouteyAchtey = streamAudio.filter(({plateforme}) => plateforme === 'Tidal' || plateforme === 'Spotify' || plateforme === 'Deezer' || plateforme === 'Soundcloud' || plateforme === 'Applemusic') const filteredKouteyAchtey = streamAudio.filter(({plateforme}) => plateforme === 'Tidal' || plateforme === 'Spotify' || plateforme === 'Deezer' || plateforme === 'Soundcloud' || plateforme === 'Applemusic')
const handleClick = (plateforme, url) => { const handleClick = (plateforme, url, titre = null) => {
if (chwaMizik && chwaMizik.plateforme === plateforme) { if (chwaMizik && chwaMizik.plateforme === plateforme) {
return meteChwaMizik(null) return meteChwaMizik(null)
} }
meteChwaMizik({plateforme, url}) meteChwaMizik({plateforme, url, titre})
} }
useEffect(() => { useEffect(() => {
@@ -141,6 +155,16 @@ function EntegreMizik({parole, isMobile}) {
return ( return (
<Box align='center'> <Box align='center'>
{!okiMizikID && gadeEmbed && (
<IconButton
aria-label='player'
size='large'
onClick={() => handleClick('Gade', gadeEmbed, titre)}
>
<Peertube />
</IconButton>
)}
{!okiMizikID && filteredKouteyAchtey.map(({id, plateforme, url}) => ( {!okiMizikID && filteredKouteyAchtey.map(({id, plateforme, url}) => (
<IconButton <IconButton
key={id} key={id}
@@ -153,7 +177,7 @@ function EntegreMizik({parole, isMobile}) {
))} ))}
{chwaMizik && ( {chwaMizik && (
<RannIframe plateforme={chwaMizik.plateforme} url={chwaMizik.url} isMobile={isMobile} /> <RannIframe plateforme={chwaMizik.plateforme} url={chwaMizik.url} titre={chwaMizik.titre} isMobile={isMobile} />
)} )}
</Box> </Box>
) )
@@ -167,7 +191,12 @@ EntegreMizik.propTypes = {
RannIframe.propTypes = { RannIframe.propTypes = {
plateforme: PropTypes.string.isRequired, plateforme: PropTypes.string.isRequired,
url: PropTypes.string.isRequired, url: PropTypes.string.isRequired,
titre: PropTypes.string,
isMobile: PropTypes.bool.isRequired isMobile: PropTypes.bool.isRequired
} }
RannIframe.defaultProp = {
titre: null
}
export default EntegreMizik export default EntegreMizik