2
0

🚸 (video) Improve video autoplay behavior

Autoplay video only when displayed entirely and fix weird Safari autoplay issues when scrolling
This commit is contained in:
Baptiste Arnaud
2023-07-07 12:02:40 +02:00
parent 31b70223c8
commit 5ae6c64d06
5 changed files with 13 additions and 5 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "@typebot.io/js",
"version": "0.0.66",
"version": "0.0.67",
"description": "Javascript library to display typebots on your website",
"type": "module",
"main": "dist/index.js",

View File

@@ -17,6 +17,14 @@ export const VideoBubble = (props: Props) => {
const [isTyping, setIsTyping] = createSignal(true)
const onTypingEnd = () => {
const videoElement = ref?.querySelector('video')
if (videoElement) {
try {
videoElement.play()
} catch (e) {
console.warn('Could not autoplay the video:', e)
}
}
if (!isTyping()) return
setIsTyping(false)
setTimeout(() => {
@@ -74,9 +82,7 @@ const VideoContent = (props: VideoContentProps) => {
}
style={{
height: props.isTyping ? '32px' : 'auto',
'max-height': window.navigator.vendor.match(/apple/i) ? '40vh' : '',
}}
autoplay
>
<source src={props.content.url} type="video/mp4" />
Sorry, your browser doesn&apos;t support embedded videos.

View File

@@ -1,6 +1,6 @@
{
"name": "@typebot.io/react",
"version": "0.0.66",
"version": "0.0.67",
"description": "React library to display typebots on your website",
"main": "dist/index.js",
"types": "dist/index.d.ts",