问题
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?
回答1:
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.
回答2:
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
来源:https://stackoverflow.com/questions/39301196/embedding-most-recent-youtube-video-with-channel-id