Make sure videos are 16:9

This commit is contained in:
Jeremy Karlsson 2023-02-03 15:20:12 +01:00
parent 43c074fa4c
commit f8fd626673
No known key found for this signature in database
GPG Key ID: 58E2A72093092D1C

View File

@ -1,4 +1,4 @@
import { useEffect, useState } from "react";
import { CSSProperties, useEffect, useState } from "react";
import { TidalRegex } from "Const";
// Re-use dom parser across instances of TidalEmbed
@ -34,6 +34,7 @@ async function oembedLookup (link: string) {
const TidalEmbed = ({ link }: { link: string }) => {
const [source, setSource] = useState<string>();
const [height, setHeight] = useState<number>();
const extraStyles = link.includes('video') ? { aspectRatio: "16 / 9" } : { height };
useEffect(() => {
oembedLookup(link).then(data => {
@ -43,7 +44,7 @@ const TidalEmbed = ({ link }: { link: string }) => {
}, [link]);
if (!source) return <a href={link} target="_blank" rel="noreferrer" onClick={(e) => e.stopPropagation()} className="ext">{link}</a>;
return <iframe src={source} height={height} width="100%" title="TIDAL Embed" frameBorder={0} />;
return <iframe src={source} style={extraStyles} width="100%" title="TIDAL Embed" frameBorder={0} />;
}
export default TidalEmbed;