我在我的网站上使用VideoJs播放器。在每个视频中,我都有第一个广告,然后是第一个视频文件。我在互联网上看过,但是找不到任何清晰的文档或一些示例来创建按钮“跳过广告” ...我只找到了 this example,但尝试时会出错
VIDEOJS: ERROR: TypeError: player.skipAds is not a function
这是我的代码:
<video id="video_1" poster="<?=$videos->getPoster(1)?>" class="video video-js vjs-default-skin" controls width="258" height="150" data-setup="{}" src="<?= $videos->getVideo(1) ?>">
<source src="<?= $videos->getVideo(1) ?>" type="video/mp4">
<div class="videojs-ads-info enabled">
<span>Your video will resume in 23 seconds</span>
<a class="enabled">Skip Ad</a>
</div>
和脚本:
videojs('#video_1', {}, function() {
var player = this;
player.ads();
player.on('contentchanged', function() {
player.trigger('adsready');
});
player.on('readyforpreroll', function() {
player.ads.startLinearAdMode();
player.src('<?=$videos->getAds(1)?>');
player.skipAds({ delayInSeconds: 10 });
player.one('adplaying', function() {
player.trigger('ads-ad-started');
});
player.one('adended', function() {
player.ads.endLinearAdMode();
});
});
player.trigger('adsready');
});