I’m trying the YouTube Javascript API so I can embed videos without YouTube suggesting other videos at the end. I had a look at the help article (which is outdated) in Webflow help center, but I think I’m doing something wrong since it’s not working! Could you please have a look at:
I actually found a bug that’s restricting us to put a ` before the javascript button links. I’ll let you know as soon as this is fixed.
Meanwhile there are a few things to fix on your page:
The code on the Webflow help page was a bit bugged and hard to read, did you make sure you put this code in custom code before /body tag?
<script>
function playthevideo(){
var myPlayer = document.getElementById('my-video');
myPlayer.playVideo();
}
function stopthevideo(){
var myPlayer = document.getElementById('my-video');
myPlayer.stopVideo();
}
function pausethevideo(){
var myPlayer = document.getElementById('my-video');
myPlayer.pauseVideo();
}
</script>
Lastly, make sure that the html embed element has a fixed height (example: 300px) because right know it wants to fill 100% of the parent element, but it can’t do that because the parent element has height: auto which will result in height 0% for the html embed.
I hope this helps and I’ll let you know once the little bug is fixed.
As as side point I would not use those instructions from the Webflow help you originally linked to, I am not sure why that page is still published, it is using old API code.
@DharmaNode I’ve done this but than the height is not the way it’s supposed to be and the movie is cramped into the video window resulting in black bars to the left and right of the video.