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

@ -1509,7 +1509,6 @@
"buttons": { "color": "#010000", "backgroundColor": "#FFEF02" },
"roundness": "medium",
"hostAvatar": {
"url": "http://localhost:9000/typebot/public/typebots/cli8tguel00011anqcst3166d/hostAvatar?v=1685368734687",
"isEnabled": true
},
"hostBubbles": { "color": "#ffffff", "backgroundColor": "#1B1A1A" },

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",

View File

@ -63,6 +63,9 @@ export const defaultTheme: Theme = {
color: '#303235',
placeholderColor: '#9095A0',
},
hostAvatar: {
isEnabled: true,
},
},
general: {
font: 'Open Sans',