我尝试使用video.js在youtube视频上制作前贴片广告(VAST)。 我在github https://github.com/eXon/videojs-youtube上使用插件,而对于AD部分我使用的是videojs-vast-plugin(https://github.com/theonion/videojs-vast-plugin)。
当我使用mp4视频格式时。前贴片广告完美运作。但是,如果我使用youtube视频。前贴片广告无效。
如何解决?我想在youtube视频上使用前贴片广告(VAST)和video.js?
这是我的代码:
<!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>
答案 0 :(得分:4)
这是禁用的,因为它会违反YouTube的服务条款
答案 1 :(得分:0)
尝试做这样的事情:
<video id="Video_ID" class="video-js vjs-default-skin vjs-big-play-centered" controls preload="metadata" >
<source type="video/youtube" src="http://www.youtube.com/watch?v=xjS6SftYQaQ">
</video>
对于你的剧本:
videojs("Video_ID", {
nativeControlsForTouch: false, //This for mobile device touch
plugins: {
//.... Your plugins
ads:{}, //perhaps you will need this for ads init
vast:{
url: "http://bs.serving-sys.com/BurstingPipe/adServer.bs?cn=is&c=23&pl=VAST&pli=13569296&PluID=0&pos=1886&ord=%%CACHEBUSTER%%&cim=1"
}
},
techOrder: ["Html5","youtube"]
},function(){
//... Player (this) is initialized and ready.
});