javascript - 使用 Video.js 在 YouTube 视频上预滚动 VAST

标签 javascript video youtube video.js video-player

我尝试使用 video.js 在 youtube 视频上制作前置广告 (VAST)。 我在 github 上使用了插件 https://github.com/eXon/videojs-youtube ,而对于广告部分,我使用的是 videojs-vast-plugin ( https://github.com/theonion/videojs-vast-plugin )。

当我使用 mp4 视频格式时。前置广告效果很好。但是,如果我使用 youtube 视频。前置广告无效。

如何解决?我想在带有 video.js 的 YouTube 视频上使用前置广告 (VAST)?

这是我的代码:

<!DOCTYPE html><html>
<head>
  <meta charset="utf-8" />
  <title>Video.js VAST Example</title>
 <link href="//vjs.zencdn.net/4.12/video-js.css" rel="stylesheet">
  <link href="videojs.ads.css" rel="stylesheet" type="text/css">
  <link href="videojs.vast.css" rel="stylesheet" type="text/css">

  <style type="text/css">
    .description {
      background-color:#eee;
      border: 1px solid #777;
      padding: 10px;
      font-size: .8em;
      line-height: 1.5em;
      font-family: Verdana, sans-serif;
    }
    .example-video-container {
      display: inline-block;
    }
  </style>
  <!--[if lt IE 9]><script src="lib/es5.js"></script><![endif]-->
  <script src="//vjs.zencdn.net/4.12/video.js"></script>
  <script src="videojs.ads.js"></script>
  <script src="vast-client.js"></script>
  <script src="videojs.vast.js"></script>
  <script src="youtube.js"></script>
</head>
<body>
<p class="description">Video.js VAST plugin with videojs-youtube.</p>

<div class="example-video-container">
<video id="video" src="" class="video-js vjs-default-skin" controls preload="none" width="640" height="264" data-setup='{ "width": "auto", "height": "auto", "techOrder": ["youtube"], "src": "https://www.youtube.com/watch?v=cn-NsWRtaSY" }'>
  </video>

<script>
var vid = videojs("video");
vid.ads();
vid.vast({
      url: 'https://pubads.g.doubleclick.net/gampad/ads?sz=640x360&iu=/6062/iab_vast_samples/skippable&ciu_szs=300x250,728x90&impl=s&gdfp_req=1&env=vp&output=xml_vast2&unviewed_position_start=1&url=[referrer_url]&correlator=[timestamp]'
    });
	
</script>

</div>

  
</body>
</html>

最佳答案

这已被禁用,因为它会违反 YouTube 的服务条款

参见:https://github.com/eXon/videojs-youtube/issues/177

关于javascript - 使用 Video.js 在 YouTube 视频上预滚动 VAST,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29659605/

相关文章:

javascript - 数据表以编程方式应用过滤器

javascript - Ng-Switch 破坏 <select> 默认/Ng-Init 值

video - 具有从左到右过渡的 Ffmpeg 图像叠加

javascript - iFrame 嵌入的 youtube 引用 api 未加载 iFrame

video - 如何在LaTeX Beamer中设置嵌入式YouTube视频的视频质量

php - 如何在PHP中将键值添加到解码的json中?

javascript - 将适配器与 Lawnchair 一起使用

video - 不使用 DirectShow 作为 Windows 的 CUDA 视频处理管道的基础是不是很愚蠢?

c++ - 通过网络同步视频播放

javascript - 对象预期错误