# Autoplay HTML code

**URL:** <https://forum.bubble.io/t/autoplay-html-code/315743>\
**Category:** Need help\
**Created:** [April 2, 2024, 8:39pm UTC](https://forum.bubble.io/t/autoplay-html-code/315743 "2024-04-02T20:39:33Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![jpdougherty24](https://avatars.discourse-cdn.com/v4/letter/j/9e8a1a/32.png) [@jpdougherty24](https://forum.bubble.io/u/jpdougherty24)\
**Post date:** [April 2, 2024, 8:39pm UTC](https://forum.bubble.io/t/autoplay-html-code/315743/1 "2024-04-02T20:39:33Z")

</div>

I am using this code to enable autoplay for an HTML on my page.

 ![Screenshot 2024-04-02 at 3.13.38 PM](https://us1.discourse-cdn.com/bubble/original/3X/b/b/bbe7505d02b6f6df305e6902bf52b605225b084e.png)

It is working on a desktop perfectly. However, it is not working on a mobile phone. What is wrong/missing in the code for it to also autoplay the HTML on a mobile device? I have spent the last 4 hours breaking down the workflows and the issue seems to be in this code. Any suggestions?

---

<div class="post-metadata">

**Author:** ![igor.tad](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/igor.tad/32/211100_2.png) [@igor.tad](https://forum.bubble.io/u/igor.tad)\
**Post date:** [April 2, 2024, 9:53pm UTC](https://forum.bubble.io/t/autoplay-html-code/315743/2 "2024-04-02T21:53:18Z")

</div>

Welcome to hell. I spent 400 hours on this problem.  
DELETE EVERYTHING FROM HTML CODE PLACE  
Create custom state playmusic yes/no  
On HTML conditional make it when playmusic is yes text: html code you want.

Viola!  
When you want to pause the player just set playmusic to no!

Autoplay wont work on phone if you leave it just on HTML you need state to trigger it!

You are welcome!

---

<div class="post-metadata">

**Author:** ![jpdougherty24](https://avatars.discourse-cdn.com/v4/letter/j/9e8a1a/32.png) [@jpdougherty24](https://forum.bubble.io/u/jpdougherty24)\
**Post date:** [April 2, 2024, 11:19pm UTC](https://forum.bubble.io/t/autoplay-html-code/315743/3 "2024-04-02T23:19:42Z")

</div>

We are getting close but it is still not working. There must be an error with something that I did on my part. Here you can see I made the following changes:  
I added a yes/no custom state called play music to the page

 ![Screenshot 2024-04-02 at 7.09.06 PM](https://us1.discourse-cdn.com/bubble/original/3X/7/d/7d1651102d8d094f9bc1fbfc7c8d163d99a93b3b.png)  
I then erased everything on the appearence tab and created a conditional statement (if playmusic is yes) and pasted the autoplay html code in there.  
 ![Screenshot 2024-04-02 at 7.10.35 PM](https://us1.discourse-cdn.com/bubble/original/3X/c/a/cadcd1a173f5abc80de58976a5268618992e935c.jpeg)

Lastly, I added a set state of an element in the backend workflow to make sure to make the playmusic condition “yes” so that it can start playing its sound.

 ![Screenshot 2024-04-02 at 7.07.49 PM](https://us1.discourse-cdn.com/bubble/original/3X/c/7/c704f61e8e43f6bda88a66b9f2b0e794c965dacd.png)  
I am so thankful for you taking the time to help me with this. I completely understand where you are coming from. I have been trying to fix this issue since last night and feel your pain. I cannot imagine 400 hours of this 🤪 I do want to emphasis that all of this still works on a desktop but the autoplay is not automatic in the mobile still. Maybe my code in the conditional section is wrong?

---

<div class="post-metadata">

**Author:** ![igor.tad](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/igor.tad/32/211100_2.png) [@igor.tad](https://forum.bubble.io/u/igor.tad)\
**Post date:** [April 5, 2024, 6:49pm UTC](https://forum.bubble.io/t/autoplay-html-code/315743/4 "2024-04-05T18:49:36Z")

</div>

It may be backend workflow, can you just for test put button to change playmusic state in app from regular workflow not backend?

---

<div class="post-metadata">

**Author:** ![igor.tad](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/igor.tad/32/211100_2.png) [@igor.tad](https://forum.bubble.io/u/igor.tad)\
**Post date:** [April 5, 2024, 6:54pm UTC](https://forum.bubble.io/t/autoplay-html-code/315743/5 "2024-04-05T18:54:37Z")

</div>

Actually how I really did it at the end (JUST CHECKED, sorry) I put on HTML when parameter page is Login then html code, maybe parameter is actually what is triggering it. check my app it works [Flasker.io](https://flasker.bubbleapps.io/version-test/) background videos are html autoplayed as you see. Will send you images of my conditionals on html, cant go to editor right now it seems bubble is down for me.

---

<div class="post-metadata">

**Author:** ![igor.tad](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/igor.tad/32/211100_2.png) [@igor.tad](https://forum.bubble.io/u/igor.tad)\
**Post date:** [April 5, 2024, 7:04pm UTC](https://forum.bubble.io/t/autoplay-html-code/315743/6 "2024-04-05T19:04:15Z")

</div>

![image](https://us1.discourse-cdn.com/bubble/original/3X/0/3/0316410083b84e9a6e75a0f54d7673dc24a59967.jpeg)  
 ![image](https://us1.discourse-cdn.com/bubble/original/3X/5/0/50672f5fbfed4ff0ce88ad59a832145e75fd9ebd.png)

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/bubble/original/3X/2/8/2847faa74692c2ffa5d939d3dc3724cdd060d247.png) [@system](https://forum.bubble.io/u/system)\
**Post date:** [June 11, 2024, 8:40pm UTC](https://forum.bubble.io/t/autoplay-html-code/315743/7 "2024-06-11T20:40:07Z")

</div>

This topic was automatically closed after 70 days. New replies are no longer allowed.
