You can adapt your code to work with YouTube embeds. Set the youtube embed src to the following:
controls=0 – Removes the player controls (like play, pause, volume).
modestbranding=1 – Minimizes the YouTube logo in the player.
rel=0 – Prevents showing related videos at the end (only works to show videos from the same channel).
showinfo=0 – Removes the video title and uploader info (this parameter is deprecated but modestbranding should help).
fs=0 – Disables the fullscreen button.
iv_load_policy=3 – Hides video annotations (like pop-up notifications).
Then have your code detect for youtube embed urls and use a iframe to create the player (rather than a video tag). Finally map your player controls to the youtube embed api. Plyr.io have done something similar.
controls=0 – Removes the player controls (like play, pause, volume). modestbranding=1 – Minimizes the YouTube logo in the player. rel=0 – Prevents showing related videos at the end (only works to show videos from the same channel). showinfo=0 – Removes the video title and uploader info (this parameter is deprecated but modestbranding should help). fs=0 – Disables the fullscreen button. iv_load_policy=3 – Hides video annotations (like pop-up notifications).
Then have your code detect for youtube embed urls and use a iframe to create the player (rather than a video tag). Finally map your player controls to the youtube embed api. Plyr.io have done something similar.