Embedding most recent YouTube video with Channel I

2019-06-14 04:05发布

I am building a website for a friend and I'm having some trouble with the YouTube player API. This is the embed HTML IFrame I have so far:

<body>    
    <iframe style="max-width: 480px" width="100%" height="360" src="http://www.youtube.com/embed?max-results=1&controls=0&showinfo=0&rel=0&listType=user_uploads&list=UCvDJ_vg2dics1kmwUPnTo_A" frameborder="0" allowfullscreen></iframe>
</body> 

This does not work due to the fact that his YouTube channel uses the new ID system and it doesn't detect that in the "user_uploads" type. Any ideas?

2条回答
等我变得足够好
2楼-- · 2019-06-14 04:32

With new channels, that do not have a username, you should use:

http://www.youtube.com/embed/videoseries?list=USERID

And the USERID is your youtube user id with 'UU' appended.

For example, if your user id is TlQ5niAIDsLdEHpQKQsupg then you should put UUTlQ5niAIDsLdEHpQKQsupg. If you only have the channel id (which you can find in your channel URL) then just replace the first two characters (UC) with UU.

So in the end you would have an URL like this: http://www.youtube.com/embed/videoseries?list=UCTlQ5niAIDsLdEHpQKQsupg

BTW. you can append &index=1 to specify which video should be played.

See answer on duplicate

查看更多
狗以群分
3楼-- · 2019-06-14 04:38

It is stated in the Player Parameter of Iframe API that the list parameter, in conjunction with the listType parameter, identifies the content that will load in the player.

  • If the listType parameter value is user_uploads, then the list parameter value identifies the YouTube channel whose uploaded videos will be loaded.

It is not stated here that you need to place Channel ID in the list parameter. The list parameter value identifies the YouTube channel whose uploaded videos will be loaded.

So what you need to place here is the USER NAME.

example

https://www.youtube.com/user/Nightblue3

Try to use the Nightblue3 here in the list parameter of your request. And your embed video will work.

For more information, check this related SO question.

查看更多
登录 后发表回答