我想投放 IMA 广告,但在出错时向 VAST 投放“瀑布”广告。有可能做到吗?
据我所知,当您初始化 jwplayer 时,您必须设置客户端(“vast”或“googima”),因此我们无法在“onAdError”事件中更改客户端。
在“onAdError”事件中设置客户端的任何选项?
这就是我想要做的:
var aAds = [ {
client: "vast",
tag: "http://foo.com/vast.xml"
}, {
client: "googima",
tag: "http://foo.com/ima.xml"
}];
jwplayer("container1").setup({
image: "http://foo.com/bar.png",
file: "http://foo.com/bar.mp4",
advertising: {
client: "vast" // This is mandatory, isn't it?
}
});
var iAd = 0;
function showNextAdd( onPlay ) {
if (onPlay && iAd > 0) return;
if (iAd < aAds.length) {
jwplayer().playAd( aAds[iAd++].tag );
}
}
// Try first add on start
jwplayer().onPlay( function(){
showNextAdd(true);
});
// If error try next
jwplayer().onAdError( showNextAdd );