-
Notifications
You must be signed in to change notification settings - Fork 2
/
vpaid.html
140 lines (116 loc) · 5.04 KB
/
vpaid.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
<!DOCTYPE html>
<html>
<title></title>
<head>
<!-- Chang URLs to wherever Video.js files will be hosted -->
<link href="video-js.css" rel="stylesheet" type="text/css">
<!-- video.js must be in the <head> for older IEs to work. -->
<script src="video.js"></script>
<!-- Unless using the CDN hosted version, update the URL to the Flash SWF -->
<script>
videojs.options.flash.swf = "video-js.swf";
</script>
</head>
<body onload="SomeJavaScriptCode()">
<div style="marigin:0 auto;">
<!-- <button id="initAdButton" style="font-size:14px;padding:3px;" disabled>initAd</button> -->
<button id="startAdButton" style="font-size:14px;padding:3px; display: none;" disabled>startAd</button>
<div id="videoWrapper" style="">
<!-- <video id="videoElement" controls style="width:480px;height:270px;">
</video> -->
<video id="videoElement" class="video-js vjs-default-skin" controls preload="none" width="640" height="264"
poster="http://video-js.zencoder.com/oceans-clip.png"
>
<source src="http://video-js.zencoder.com/oceans-clip.mp4" type='video/mp4' />
</video>
</div>
</div>
</body>
<script type="text/javascript">
function SomeJavaScriptCode(){
setTimeout( function(){
var creativeData = {},
environmentVars = {
slot: videoWrapper,
videoSlot: videoElement,
videoSlotCanAutoPlay: true,
LR_PUBLISHER_ID: 1331,
LR_TAGS: 'demo'
};
//initAdButton.setAttribute('disabled', 'disabled');
//Initializean ad
LiveRailVPAID.initAd(videoElement.offsetWidth, videoElement.offsetHeight, 'normal', 512, creativeData, environmentVars);
}, 2000);
}
/*(function() {*/
var LiveRailVPAID,
vpaidFrame,vpaidLoader,videoWrapper = document.getElementById('videoWrapper'),
videoElement = document.getElementById('videoElement'),
initAdButton = document.getElementById('initAdButton'),
startAdButton = document.getElementById('startAdButton');
//Adinitialization stage
var initAdButton = document.getElementById('initAdButton');
/*initAdButton.onclick = function() {
};*/
//Adstart stage
startAdButton.onclick = function() {
startAdButton.setAttribute('disabled', 'disabled');
//Start thead--thismayonlybe calledafterAdLoaded is received
LiveRailVPAID.startAd();
};
//Resetplayerwith content
function playerReset() {
//Load content(playercantakecontrolatthispoint)
if (videoElement.canPlayType('video/mp4') === '' && videoElement.canPlayType('video/webm') !== '') {
videoElement.src = 'http://cdn-static.liverail.com/sample/html5/uivideo.webm';
} else {
videoElement.src = 'http://cdn-static.liverail.com/sample/html5/uivideo.mp4';
videoElement.src = 'http://video-js.zencoder.com/oceans-clip.mp4';
}
videoElement.load();
console.log( 'playerReset ');
//initAdButton.removeAttribute('disabled');
}
//DefineinitialVPAID setup
function onVPAIDLoad() {
//Subscribetoevents
LiveRailVPAID.subscribe(function() {
startAdButton.removeAttribute('disabled');
videojs("videoElement", {}, function(){
// Player (this) is initialized and ready.
});
LiveRailVPAID.startAd();
}, 'AdLoaded');
LiveRailVPAID.subscribe(function() {
playerReset();
videojs("videoElement").play();
}, 'AdStopped');
LiveRailVPAID.subscribe(function() {
playerReset();
}, 'AdError');
LiveRailVPAID.subscribe(function(message) {
console.log(message);
console.log('message');
}, 'AdLog');
LiveRailVPAID.subscribe(function(message) {
console.log('------------ complete');
}, 'AdComplete');
playerReset();
}
//Loadthe LiveRail VPAIDadunit
vpaidFrame = document.createElement('iframe');
vpaidFrame.style.display = 'none';
vpaidFrame.onload = function() {
vpaidLoader = vpaidFrame.contentWindow.document.createElement('script');
vpaidLoader.src = 'http://cdn-static.liverail.com/js/LiveRail.AdManager-1.0.js';
vpaidLoader.onload = function() {
LiveRailVPAID = vpaidFrame.contentWindow.getVPAIDAd();
LiveRailVPAID.handshakeVersion('2.0');
onVPAIDLoad();
};
vpaidFrame.contentWindow.document.body.appendChild(vpaidLoader);
};
document.body.appendChild(vpaidFrame);
// }());
</script>
</html>