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:
but if I click play, it always errors:
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>`;
}
}


www.youtube.cominstead ofwww.youtube-nocookie.com? Also, please check that thevideoIdis correct. - perhaps, the URL you are handling on yourconst videoIdvariable 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?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