🐛 (bot) Improve canPlay issue fixin
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@typebot.io/js",
|
"name": "@typebot.io/js",
|
||||||
"version": "0.0.77",
|
"version": "0.0.78",
|
||||||
"description": "Javascript library to display typebots on your website",
|
"description": "Javascript library to display typebots on your website",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
|
|||||||
@@ -18,25 +18,26 @@ export const AudioBubble = (props: Props) => {
|
|||||||
let audioElement: HTMLAudioElement | undefined
|
let audioElement: HTMLAudioElement | undefined
|
||||||
const [isTyping, setIsTyping] = createSignal(true)
|
const [isTyping, setIsTyping] = createSignal(true)
|
||||||
|
|
||||||
const autoPlay = () => {
|
const autoPlay = async () => {
|
||||||
|
if (isPlayed) return
|
||||||
isPlayed = true
|
isPlayed = true
|
||||||
if (audioElement)
|
try {
|
||||||
audioElement
|
if (audioElement) await audioElement.play()
|
||||||
.play()
|
} catch (e) {
|
||||||
.catch((e) => console.warn('Could not autoplay the audio:', e))
|
console.warn('Could not autoplay the audio:', e)
|
||||||
|
}
|
||||||
|
|
||||||
props.onTransitionEnd(ref?.offsetTop)
|
props.onTransitionEnd(ref?.offsetTop)
|
||||||
}
|
}
|
||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
if (audioElement)
|
if (audioElement)
|
||||||
audioElement.oncanplay = () => {
|
audioElement.oncanplay = () => {
|
||||||
if (isPlayed) return
|
|
||||||
clearTimeout(typingTimeout)
|
clearTimeout(typingTimeout)
|
||||||
setIsTyping(false)
|
setIsTyping(false)
|
||||||
setTimeout(autoPlay, showAnimationDuration)
|
setTimeout(autoPlay, showAnimationDuration)
|
||||||
}
|
}
|
||||||
typingTimeout = setTimeout(() => {
|
typingTimeout = setTimeout(() => {
|
||||||
if (isPlayed) return
|
|
||||||
setIsTyping(false)
|
setIsTyping(false)
|
||||||
setTimeout(autoPlay, showAnimationDuration)
|
setTimeout(autoPlay, showAnimationDuration)
|
||||||
}, defaultTypingDuration)
|
}, defaultTypingDuration)
|
||||||
|
|||||||
@@ -19,26 +19,26 @@ export const VideoBubble = (props: Props) => {
|
|||||||
let videoElement: HTMLVideoElement | undefined
|
let videoElement: HTMLVideoElement | undefined
|
||||||
const [isTyping, setIsTyping] = createSignal(true)
|
const [isTyping, setIsTyping] = createSignal(true)
|
||||||
|
|
||||||
const autoPlay = () => {
|
const autoPlay = async () => {
|
||||||
|
if (isPlayed) return
|
||||||
isPlayed = true
|
isPlayed = true
|
||||||
if (videoElement)
|
try {
|
||||||
videoElement
|
if (videoElement) await videoElement.play()
|
||||||
.play()
|
} catch (e) {
|
||||||
.catch((e) => console.warn('Could not autoplay the video:', e))
|
console.warn('Could not autoplay the video:', e)
|
||||||
|
}
|
||||||
props.onTransitionEnd(ref?.offsetTop)
|
props.onTransitionEnd(ref?.offsetTop)
|
||||||
}
|
}
|
||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
if (videoElement)
|
if (videoElement)
|
||||||
videoElement.oncanplay = () => {
|
videoElement.oncanplay = () => {
|
||||||
if (isPlayed) return
|
|
||||||
clearTimeout(typingTimeout)
|
clearTimeout(typingTimeout)
|
||||||
setIsTyping(false)
|
setIsTyping(false)
|
||||||
setTimeout(autoPlay, showAnimationDuration)
|
setTimeout(autoPlay, showAnimationDuration)
|
||||||
}
|
}
|
||||||
typingTimeout = setTimeout(
|
typingTimeout = setTimeout(
|
||||||
() => {
|
() => {
|
||||||
if (isPlayed) return
|
|
||||||
setIsTyping(false)
|
setIsTyping(false)
|
||||||
setTimeout(autoPlay, showAnimationDuration)
|
setTimeout(autoPlay, showAnimationDuration)
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@typebot.io/react",
|
"name": "@typebot.io/react",
|
||||||
"version": "0.0.77",
|
"version": "0.0.78",
|
||||||
"description": "React library to display typebots on your website",
|
"description": "React library to display typebots on your website",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"types": "dist/index.d.ts",
|
"types": "dist/index.d.ts",
|
||||||
|
|||||||
Reference in New Issue
Block a user