0

I need to insert autoplaying YouTube video in Markdown, VS Code, how can I do it?

![video](YouTube link)
  • 1
    "Autoplaying" will depend heavily on your intended environment. Are you using VSCode to _edit_ the file, or do you expect your users to run VSCode too? In many environments it will be impossible. But even if you manage to to this, it is _extremely annoying_ and I urge you to reconsider. – ChrisGPT was on strike Sep 25 '21 at 14:22
  • You could try [this](https://stackoverflow.com/a/14276834/4826457) workaround... – Suraj Rao Sep 25 '21 at 14:23
  • @Suraj Rao I use VSCode to edit the file and use preview in it too. So I just wanna play video in preview screen in VSCode automatically – Денис Попков Sep 25 '21 at 14:27

2 Answers2

2

In case you can't use HTML elements like iframe

I made an API which gets the video's thumbnail, then adds a play button and backdrop to it.

You can use it in markdown like this:

[![](https://markdown-videos-api.jorgenkh.no/youtube/{video_id})](https://youtu.be/{video_id})

Clicking on the image will open the video in your browser.

Demo:

[![](https://markdown-videos-api.jorgenkh.no/youtube/dQw4w9WgXcQ)](https://youtu.be/dQw4w9WgXcQ)

GitHub repo can be found here -> https://github.com/Snailedlt/Markdown-Videos

Edit

I also made a website to generate the code for you based on the link: https://markdown-videos.jorgenkh.no/

Snailedlt
  • 460
  • 6
  • 14
0

Open YouTube video in your browser → Press ShareEmbedCopy iframe and paste it in your markdown document.

Or just copy code the below and replace YOUTUBE_LINK with your link

<center>
 <iframe width="560" 
         height="315" 
         src="YOUTUBE_LINK" 
         title="YouTube video player" 
         frameborder="0" 
         allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" 
         allowfullscreen>
 </iframe>
</center>
Tahmid Ali
  • 805
  • 9
  • 29
Basilios
  • 11
  • 2