3

I am making a Visual Studio Code extension that generates a color theme based off a random Discogs album. I want to embed a YouTube video URL inside the Visual Studio Code sidebar extension window, I can get the video embedded, but if I click play, it reloads. I click play again, then it says An error occurred. Please try again later. (Playback ID: xAB0pWFBd-y7i0op)

In this image, you can see the YouTube video embed seems okay at first:

Enter image description here

but if I click play, it always errors:

Enter image description here

My code is available on GitHub. To set up, I just run npm i --legacy-peer-deps and then start debugging in Visual Studio Code to launch the window. Then I click "Generate from discogs release" to embed a new video.

My YouTube embed code looks like so. Is there a way to change it so the YouTube embed in Visual Studio Code works?

if (this._currentVideoUrl) {
  const videoId = this._currentVideoUrl.split('v=')[1]?.split('&')[0];
  if (videoId) {
    videoSection = `
      <div class="section">
        <h3>🎬 Release Video</h3>
        <div class="video-container">
          <iframe
            src="https://www.youtube-nocookie.com/embed/${videoId}?modestbranding=1&rel=0&controls=1&enablejsapi=0"
            title="YouTube video"
            frameborder="0"
            allow="accelerometer; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
            allowfullscreen
            width="100%"
            height="203"
            class="youtube-frame">
          </iframe>
          <a href="${this._currentVideoUrl}" class="video-link" target="_blank">
            🎬 Watch on YouTube
          </a>
        </div>
      </div>`;
  }
}
5
  • Can you please try with www.youtube.com instead of www.youtube-nocookie.com? Also, please check that the videoId is correct. - perhaps, the URL you are handling on your const videoId variable has more parameters on the URL / characters on the URL?. In addition, it would be possible to share the link of the YouTube video/playlist you are getting this error with? Commented Oct 14 at 16:24
  • I've edited my code and pushed to the main branch a verison with a hardcoded video ID I know should play, I removed everything after the '/embed' text and changed it to youtube.com instead of nocookie: src="https://www.youtube.com/embed/_5Qp-6U3_Rs" but the video still wont play in the same way as the error I describe in my question Commented Oct 14 at 18:59
  • No extension was able to embed youtube video in vscode, just search marketplace. Commented Oct 19 at 2:01
  • @redoc no one was able to walk on the moon either until somebody did it Commented Oct 21 at 16:58
  • Fine this would mostly but be too much work for you, you need something like ytdlp on user pc to stream youtube video and you can play that in vscode Commented Oct 22 at 2:02

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.