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/')) {
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/')) {

View File

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