【问题标题】:Is it possible to disable cookies for YouTube API iFrame Player是否可以禁用 YouTube API iFrame Player 的 cookie
【发布时间】:2017-09-11 17:12:47
【问题描述】:

我想知道在使用 API 时是否有“nocookie”选项? https://developers.google.com/youtube/iframe_api_reference

【问题讨论】:

    标签: youtube youtube-api


    【解决方案1】:

    可以使用无 cookie 域覆盖默认主机。示例:

    player = new YT.Player('youtubePlayer', {
        videoId : ID,
        height : '300px',
        width : '100%',
        host: 'http://www.youtube-nocookie.com',
        playerVars: {rel: 0},
        events : {
            'onReady' : onPlayerReady,
            'onStateChange' : onPlayerStateChange
        }
    });
    

    【讨论】:

    • 首先 - 它看起来像是在运行但在 js 控制台中它在播放开始时向我显示了这个错误:“XML-Verarbeitungsfehler: Kein Wurzel-Element gefunden Adresse:youtube-nocookie.com/get_midroll_info?.. ..” - 英文没有找到 XML 根元素 -> 然后是 Youtube URL 和这个 modroll 的东西?
    【解决方案2】:

    这是您可以使用的github code。

    我从SO post得到了参考

    帖子中还给出了free cookie law tools的功能。

    另一种方法是使用 www 版本,这是SO post 中给出的答案。

    这也是他们的自动代码生成器输出的版本, 当您选择扩展隐私选项时。

    看起来他们出于某种原因删除了非 www 版本。 (虽然 在不添加自动重定向的情况下这样做将是一种 奇怪的举动。也许这只是一个暂时的问题或错误。)

    【讨论】:

      【解决方案3】:

      如果您对 iframe 使用 src 属性:

      src="http://www.youtube-nocookie.com/embed/video_id?.."
      

      【讨论】:

        猜你喜欢
        • 2020-12-26
        • 2017-09-20
        • 2023-04-08
        • 2015-11-27
        • 2013-10-24
        • 1970-01-01
        • 1970-01-01
        • 2012-09-14
        • 2022-11-10
        相关资源
        最近更新 更多