iframe - 未在 YouTube 上展示的广告嵌入 iframe
问题描述
我已经使用 js 来包含 iframe youtube embed
<html>
<body>
<div id="video"></div>
</body>
<script>
// JS
var tag = document.createElement("script");
tag.src = "https://www.youtube.com/iframe_api";
var firstScriptTag = document.getElementsByTagName("script")[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
function onYouTubeIframeAPIReady() {
video = new YT.Player("video", {
height: 360,
width: 640,
videoId: "rfYydagxcJI",
host: "https://www.youtube.com",
playerVars: {
fs: 0,
modestbranding: 1,
playsinline: 1,
rel: 0,
},
});
}
</script>
</html>
我也尝试添加
<iframe width="560" height="315" src="https://www.youtube.com/embed/goSiidPyiYA" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
但这两者都没有按照 YouTube 显示任何来自 YouTube 的广告。
解决方案
如果嵌入式网站不值得信赖,Google 可能不会显示广告,以下信息来自 Google。
嵌入式视频上的广告要求
广告出现在品牌安全网站上:YouTube 努力工作,以便我们广告客户的品牌出现在反映我们各自核心价值观的网站上。在确定是否在 YouTube 嵌入中启用视频插播广告时,我们的系统会根据各种因素仔细评估网站及其内容。这些因素包括一套严格的关于成人图像、暴力、不当和仇恨语言以及宣传侵权的网站等内容的指导方针。
播放器详细信息:我们要求视频播放器看起来足够大,以促进积极的用户体验。我们建议使用 560x315 像素或更大的播放器。此外,视频应该使用标准的点击播放嵌入而不是脚本播放来嵌入。
推荐阅读
- java - 如何从 JavaFX 文本区域复制带有样式的文本?
- javascript - Javascript 读取错误的宽度值
- javascript - How to create a pixel-perfect clipping region with HTML Canvas?
- javascript - Changing color of circle mouse when moving to new section
- node.js - 无法使用 googleapis 从 Google Drive 下载文件
- arrays - 2D array definition with macros in C: weird behaviour
- gstreamer - Gstreamer stream audio over network
- uwp - HoloLens 上的 FileOpenPicker 提供来自 OneDrive 的不完整文件
- junit - 第一次失败测试后停止测试运行程序
- python - 如何使用 Flask wtf Form 发送电子邮件附件?