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