[FIXED] Youtube Script Error

Hello Friends.
This should go into a bug report.
I was having an issue when I created a youtube element on my application, so to mock out the functionality I added a Youtube element through the designer and was greeted with a script error message on my site when viewing the video.

After fiddling around with the problem, I removed the mute video flag and that solved the problem.
I am assuming that this was working at some point an that perhaps the Youtube API changed under the hood to another version.

To clarify the use case I would like to load the youtube element and have it auto play but needs it to be muted, for this particular application.

Please let me know if more information is needed.
Best Regards
Jesper

Hello @JayKayAce and welcome,

@bridget As mentioned in this post, I just wanted to let you know that the mute property on a YouTube component leads to an “internal server error” and the app logs say :null.

Clone:
https://anvil.works/build#clone:ZBXYMDU6LQRCQOR5=BGQXL2G7QK2COHWBMQZUBIE5

2 Likes

Thank you for the welcome @alcampopiano
I was looking through the existing posts and tried to find someone else who have had the same set of problems, but did not find a solution. So I tried to debug what was causing the problem, and hopefully lead the Dev team in the right direction.

All the best
Jesper

As a workaround I tried to set the player volume to both 0 and 1 in the code of my form, and while it changed in the player, it had no effect on the video.

Best Regards
Jesper

As a workaround you can use a custom html form and paste the embed link from youtube.

example:

<iframe width="560" height="315" src="https://www.youtube.com/embed/bW-OLcZ4tGY?controls=0&autoplay=1&mute=1" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>

adding the parameters

?controls=0&autoplay=1&mute=1

to the src link will give you the behaviour you want.


Be sure to check that video allows embedding.

Simply go to a new browser tab and open the embed link to see if it plays:

https://www.youtube.com/embed/bW-OLcZ4tGY?controls=0&autoplay=1&mute=1

Thanks @alcampopiano and @JayKayAce. We’re looking into this now, and I’ve moved it to Bug reports.

@alcampopiano thanks, once again, for getting that song stuck in my head :joy:

2 Likes

This has now been fixed. The change will go live in the next few days :slight_smile:

2 Likes