Skip to content

Commit

Permalink
chore: disable video preview autoplay when embedded in a super note […
Browse files Browse the repository at this point in the history
…skip e2e]
  • Loading branch information
amanharwara committed Apr 21, 2024
1 parent cdb380d commit b5dbbae
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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/')) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ type Props = {
file: FileItem
filesController: FilesController
objectUrl: string
isEmbeddedInSuper: boolean
}

/**
Expand All @@ -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)

Expand Down Expand Up @@ -65,7 +66,7 @@ const VideoPreview = ({ file, filesController, objectUrl }: Props) => {
<video
className="h-full w-full"
controls
autoPlay
autoPlay={!isEmbeddedInSuper}
onError={() => {
setShouldTryFallback(true)
}}
Expand Down

0 comments on commit b5dbbae

Please sign in to comment.