🚸 (video) Improve video autoplay behavior
Autoplay video only when displayed entirely and fix weird Safari autoplay issues when scrolling
This commit is contained in:
@ -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" },
|
||||
|
@ -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",
|
||||
|
@ -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't support embedded videos.
|
||||
|
@ -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",
|
||||
|
@ -63,6 +63,9 @@ export const defaultTheme: Theme = {
|
||||
color: '#303235',
|
||||
placeholderColor: '#9095A0',
|
||||
},
|
||||
hostAvatar: {
|
||||
isEnabled: true,
|
||||
},
|
||||
},
|
||||
general: {
|
||||
font: 'Open Sans',
|
||||
|
Reference in New Issue
Block a user