2
0

🐛 (bot) Improve canPlay issue fixin

This commit is contained in:
Baptiste Arnaud
2023-07-12 15:06:39 +02:00
parent 082084a90c
commit 0b4b15ce0a
4 changed files with 17 additions and 16 deletions

View File

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

View File

@ -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)

View File

@ -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)
},

View File

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