Member-only story

How To Create a Simple YouTube Player With JavaScript

A brief guide to a fun player

Samuele
Better Programming
3 min readAug 29, 2022

One of my most successful open source projects is my collection of templates for Construct 3. Not so much the part dedicated to video games as the one where I experimented with integrating JavaScript and event sheets. I think it might be useful to give some tips on creating a custom YouTube video player with JavaScript.

First, let’s see what I want to achieve:

The interface is quite simple. Most of the screen is taken up by video. At the top, there is space for the title, and on the right some buttons to control playback ( Play, Pause, Stop, and the volume). Still on the right, but further down, some buttons allow you to choose which video to play and possibly to select others via the YouTube ID.

It is a project designed as a demonstration, so I put the ability to view YouTube videos starting from two separate JSON files in the code. The first with the video IDs, the second with the URLs. Of course, you can choose your preferred method.

You can also download the code from this link: simple-youtube-player.c3p.

Samuele
Samuele

Written by Samuele

I'm a hobby programmer, experimenting with Svelte, Javascript, Construct 3 and magic tools

No responses yet

What are your thoughts?