Passing the "video index" of a playlist in a Youtube iframe

Asked

Viewed 119 times

0

I’m creating a site where I want to display the last two videos posted on a particular channel, but I can’t pass the parameters of index of the video by src of iframe as shown below:

<iframe 
  src="https://www.youtube.com/embed?listType=playlist&list=PLYFQKMIdrXSbuNYzQmrc8ocTdT6u4EZGe&index=0"
  frameborder="0" 
  allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" 
  allowfullscreen></iframe>

<iframe 
  src="https://www.youtube.com/embed?listType=playlist&list=PLYFQKMIdrXSbuNYzQmrc8ocTdT6u4EZGe&index=1" 
  frameborder="0" 
  allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" 
  allowfullscreen></iframe>

Can someone help me with a possible solution to my problem?

  • Hello @Lucas Welcome to Sopt, before starting a look at our [Tour], -- I made an edition in the description of your question, if my edition does not represent your doubt you can reverse it at this link -- =D

2 answers

1

Brother, if you put it like that you’ll see it works.. the problem in your case is that the video with index = 1, is a private video or is broken and cannot be added to embed!

<iframe
  src="https://www.youtube.com/embed?listType=playlist&list=PLYFQKMIdrXSbuNYzQmrc8ocTdT6u4EZGe&index=0"
  frameborder="0"
  allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture"
  allowfullscreen></iframe>

<iframe
  src="https://www.youtube.com/embed?listType=playlist&list=PLYFQKMIdrXSbuNYzQmrc8ocTdT6u4EZGe&index=3"
  frameborder="0"
  allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture"
  allowfullscreen></iframe>

0

I did it this way and it didn’t work out, but I did it... I’ll post the solution here in case anyone else looks into it:

//Último Vídeo postado no canal
<iframe src="https://www.youtube.com/embed/videoseries?list=[UPLOAD_PLAYLIST_ID]&index=0" frameborder="0" allowfullscreen></iframe>

//Penúltimo Vídeo postado no canal
<iframe src="https://www.youtube.com/embed/videoseries?list=[UPLOAD_PLAYLIST_ID]&index=1" frameborder="0" allowfullscreen></iframe>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.