Created
May 29, 2017 13:06
-
-
Save boyangwang/bc04608de6cedcfdff56100570c9b441 to your computer and use it in GitHub Desktop.
vidgyor promo no delay ver 2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<script src="//player2.h-cdn.com/hola_player.dev.js?customer=boyang_test"></script> | |
</head> | |
<body> | |
<div><h1>Video tag with Hola player - playing HLS</h1></div> | |
<div id="wrapper"> | |
<video id="stream" preload="none" class="video-js vjs-default-skin" width="640" height="360" controls> | |
<source | |
src="http://wowza.streamroot.io/liveorigin/stream1/playlist.m3u8" | |
type="application/x-mpegurl"> | |
</video> | |
</div> | |
<div id="log"> | |
Log: | |
</div> | |
<script> | |
var log_div = document.getElementById('log'); | |
function log(){ | |
log_div.innerHTML = | |
log_div.innerHTML + '<br/>' + | |
Array.prototype.join.call(arguments, ' '); | |
}; | |
var adTagUrl = 'https://pubads.g.doubleclick.net/gampad/ads?sz=640x360&iu=/106213651/Pilot-Midroll3&impl=s&gdfp_req=1&env=vp&output=vast&unviewed_position_start=1&url=[referrer_url]&description_url=[description_url]&correlator=[timestamp]'; | |
window.hola_player({ | |
player: "#stream", | |
auto_play: true, | |
ads: { | |
manual: true | |
} | |
}, function(v){ | |
v.on([ | |
'readyforpreroll', | |
'contentplayback', | |
'adsready', | |
'adplaying', | |
'adscanceled', | |
'adserror', | |
'nopreroll', | |
'nopostroll', | |
'adend', | |
'adskip', | |
'adstart', | |
'ads-ad-started', | |
'ads-request', | |
'ads-load', | |
'ads-pod-started', | |
'ads-pod-ended', | |
'ads-allpods-completed', | |
'ads-ad-started', | |
'ads-ad-ended', | |
'ads-ad-skip', | |
'ads-ad-skipped', | |
'ads-skipped', | |
'ads-skip', | |
'ads-first-quartile', | |
'ads-midpoint', | |
'ads-third-quartile', | |
'ads-pause', | |
'ads-play', | |
'ads-mute', | |
'ads-click', | |
], function(e){ | |
log(e.type); | |
}); | |
var ad_played = false; | |
var start_time; | |
v.on('timeupdate', function(){ | |
var cur = v.currentTime(); | |
if (!start_time) { | |
return start_time = cur; | |
} | |
if (!ad_played && cur - start_time > 5) { | |
v.ima.playAd(adTagUrl); | |
ad_played = true; | |
} | |
}); | |
v.on('ads-ad-skipped', function(){ | |
v.ads.endLinearAdMode(); | |
v.trigger('adstart'); | |
v.src('http://streamer5.vidgyor.com/vod-origin/promos/yupptv/yupptv_promo_1.mp4'); | |
v.one('adend', function() { | |
v.ads.endLinearAdMode(); | |
}); | |
}); | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment