Skip to content

Commit

Permalink
⚡ (audio) Implement more robust auto play
Browse files Browse the repository at this point in the history
  • Loading branch information
baptisteArno committed Jul 12, 2023
1 parent d6c6434 commit 0a85f33
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 13 deletions.
2 changes: 1 addition & 1 deletion packages/embeds/js/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@typebot.io/js",
"version": "0.0.79",
"version": "0.0.80",
"description": "Javascript library to display typebots on your website",
"type": "module",
"main": "dist/index.js",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,34 @@ const typingDuration = 500
let typingTimeout: NodeJS.Timeout

export const AudioBubble = (props: Props) => {
let isPlayed = false
let ref: HTMLDivElement | undefined
let audioElement: HTMLAudioElement | undefined
const [isTyping, setIsTyping] = createSignal(true)

const endTyping = () => {
if (isPlayed) return
isPlayed = true
setIsTyping(false)
setTimeout(
() => props.onTransitionEnd(ref?.offsetTop),
showAnimationDuration
)
}

onMount(() => {
typingTimeout = setTimeout(() => {
setIsTyping(false)
setTimeout(() => {
const audioElement = ref?.querySelector('audio')
if (audioElement)
audioElement
.play()
.catch((e) => console.warn('Could not autoplay the audio:', e))
props.onTransitionEnd(ref?.offsetTop)
}, showAnimationDuration)
}, typingDuration)
typingTimeout = setTimeout(endTyping, typingDuration)
audioElement?.addEventListener(
'canplay',
() => {
clearTimeout(typingTimeout)
audioElement
?.play()
.catch((e) => console.warn("Couldn't autoplay audio", e))
endTyping()
},
{ once: true }
)
})

onCleanup(() => {
Expand Down
2 changes: 1 addition & 1 deletion packages/embeds/react/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@typebot.io/react",
"version": "0.0.79",
"version": "0.0.80",
"description": "React library to display typebots on your website",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down

2 comments on commit 0a85f33

@vercel
Copy link

@vercel vercel bot commented on 0a85f33 Jul 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

viewer-v2 – ./apps/viewer

bii.bj
1stop.au
wasap.nl
x.cr8.ai
yobot.me
klujo.com
me.cr8.ai
wachat.io
wassep.io
247987.com
8jours.top
aginap.com
ai.mprs.in
bee.cr8.ai
bot.aws.bj
bot.bbc.bj
cat.cr8.ai
finplex.be
jxi.cr8.ai
nepkit.com
pig.cr8.ai
sat.cr8.ai
typebot.io
wachats.me
wsapio.com
blogely.com
bot.aipr.kr
bot.joof.it
bot.kloo.me
broprio.com
bull.cr8.ai
docs.cr8.ai
getyour.sbs
icon.cr8.ai
minipost.uk
mole.cr8.ai
nurraysa.me
team.cr8.ai
wolf.cr8.ai
ai.meant.com
bet7k.online
bot.afric.ai
bot.grace.bj
cinecorn.com
gniorder.com
help.taxt.co
kusamint.com
receita.info
offer.botscientis.us
ore.barrettamario.it
sellmycarglasgow.com
superglicemia.com.br
whats.laracardoso.com
www.hemertonsilva.com
zillabot.saaszilla.co
815639944.21000000.one
83720273.bouclidom.com
aplicacao.bmind.com.br
apply.ansuraniphone.my
bbutton.wpwwakanda.com
bolsamaisbrasil.app.br
bot.clubedotrader.club
bot.ilmuseoaiborghi.it
bot.louismarcondes.com
bot.pratikmandalia.com
bot.sucessodigital.xyz
bot.t20worldcup.com.au
bot.whatsappweb.adm.br
bot2.mycompany.reviews
bot3.mycompany.reviews
bot4.mycompany.reviews
c23111azqw.nigerias.io
chat.footballmeetup.ie
conto.barrettamario.it
dieta.barrettamario.it
felipewelington.com.br
form.bridesquadapp.com
form.searchcube.com.sg
gcase.barrettamario.it
go.orodrigoribeiro.com
help.giversforgood.com
info.clickasuransi.com
kodawariab736.skeep.it
mdb.diego.progenbr.com
michaeljackson.riku.ai
premium.kandabrand.com
report.gratirabbit.com
resume.gratirabbit.com
83242573.actualizar.xyz
87656003.actualizar.xyz
88152257.actualizar.xyz
91375310.actualizar.xyz
app.youvisitedthis.site
arrivalx2.wpwakanda.com
bot.blackboxtips.com.br
bot.hotelplayarimini.it
bot.messengerbet.online
chat.bebesemcolicas.com
filial.socialcliques.me
help.comebackreward.com

@vercel
Copy link

@vercel vercel bot commented on 0a85f33 Jul 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

builder-v2 – ./apps/builder

builder-v2-typebot-io.vercel.app
app.typebot.io
builder-v2-git-main-typebot-io.vercel.app

Please sign in to comment.