我试着用video.js在youtube视频上做一个预滚动广告(大量)。我在github上使用了插件,而在广告部分,我使用了这个https://github.com/eXon/videojs-youtube -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>
发布于 2015-04-17 01:18:40
这是禁用的,因为它会违反YouTube的TOS
发布于 2016-01-06 07:46:46
试着这样做:
<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.
});https://stackoverflow.com/questions/29659605
复制相似问题