【问题标题】:Youtube player iframe embed not working for my channel嵌入的 Youtube 播放器 iframe 不适用于我的频道
【发布时间】:2015-03-30 08:59:07
【问题描述】:

我正在尝试在我的网站上使用 iframe 为我的频道添加一个 youtube 播放器。

I picked up code from here

频道是-http://youtube.com/channel/UCYPhPtoN64fI2hfge6Iw_gQ

我在我的网站上的以下 html 代码 sn-p 中使用了频道 ID - UCYPhPtoN64fI2hfge6Iw_gQ

<iframe id="ytplayer" type="text/html" width="400" height="225" src="//www.youtube.com/embed/?listType=user_uploads&list=UCYPhPtoN64fI2hfge6Iw_gQ" frameborder="0" allowfullscreen></iframe>

播放器内部出现错误 -

发生错误。请稍后再试

另外,我可以在网络选项卡中看到我收到了 400 [BAD REQUEST] http 请求响应

https://www.youtube.com/list_ajax?action_get_user_uploads_by_user=1&style=xml&username=UCYPhPtoN64fI2hfge6Iw_gQ

错误是

{"errors": ["The URL contained a malformed username.", "Invalid request."]}

在使用网页上的频道 ID 嵌入此频道时,我需要帮助。任何帮助将不胜感激。

【问题讨论】:

    标签: javascript iframe youtube-api


    【解决方案1】:

    列表参数应该是用户名而不是用户ID,请尝试在此处检查您的用户名https://www.youtube.com/account_advanced

    例如:

    <iframe id="ytplayer" type="text/html" width="400" height="225" src="//www.youtube.com/embed/?listType=user_uploads&list=UKFDrumandBass" frameborder="0" allowfullscreen></iframe>
    

    它将获取用户 UKFDrumandBass 上传的所有视频

    如果您想从频道而不是用户名嵌入视频,请查看此线程How to embed a YouTube channel into a webpage

    【讨论】:

    • 我在上面发布的示例中使用了频道 ID。在youtube.com/account_advanced,我可以看到 youtube 用户 id 和 youtube 频道 id,但播放器不能同时使用两者。
    猜你喜欢
    • 2013-09-19
    • 1970-01-01
    • 2011-08-15
    • 2021-04-23
    • 2019-01-22
    • 2013-08-18
    • 2016-09-30
    • 1970-01-01
    • 2015-05-23
    相关资源
    最近更新 更多