chore: disable video preview autoplay when embedded in a super note [skip e2e]

This commit is contained in:
Aman Harwara
2024-04-21 17:02:53 +05:30
parent cdb380dbc8
commit b5dbbae3c9
2 changed files with 11 additions and 3 deletions

View File

@@ -90,7 +90,14 @@ const PreviewComponent: FunctionComponent<Props> = ({
} }
if (file.mimeType.startsWith('video/')) { if (file.mimeType.startsWith('video/')) {
return <VideoPreview file={file} filesController={application.filesController} objectUrl={objectUrl} /> return (
<VideoPreview
file={file}
filesController={application.filesController}
objectUrl={objectUrl}
isEmbeddedInSuper={isEmbeddedInSuper}
/>
)
} }
if (file.mimeType.startsWith('audio/')) { if (file.mimeType.startsWith('audio/')) {

View File

@@ -9,6 +9,7 @@ type Props = {
file: FileItem file: FileItem
filesController: FilesController filesController: FilesController
objectUrl: string objectUrl: string
isEmbeddedInSuper: boolean
} }
/** /**
@@ -17,7 +18,7 @@ type Props = {
* when not using the <source/> tag. * when not using the <source/> tag.
* We show an error message if neither works. * We show an error message if neither works.
*/ */
const VideoPreview = ({ file, filesController, objectUrl }: Props) => { const VideoPreview = ({ file, filesController, objectUrl, isEmbeddedInSuper }: Props) => {
const [showError, setShowError] = useState(false) const [showError, setShowError] = useState(false)
const [shouldTryFallback, setShouldTryFallback] = useState(false) const [shouldTryFallback, setShouldTryFallback] = useState(false)
@@ -65,7 +66,7 @@ const VideoPreview = ({ file, filesController, objectUrl }: Props) => {
<video <video
className="h-full w-full" className="h-full w-full"
controls controls
autoPlay autoPlay={!isEmbeddedInSuper}
onError={() => { onError={() => {
setShouldTryFallback(true) setShouldTryFallback(true)
}} }}