-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
60 lines (56 loc) · 1.85 KB
/
index.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
<html>
<head>
<title>Test for ConcertVast</title>
<style>
input {
width: 100%;
margin: 20px 0;
}
video {
width: 100%;
}
</style>
</head>
<body>
<input
name="vastUrl"
value="https://ad.doubleclick.net/ddm/pfadx/N3493.3018656VOX-CONCERT/B22204404.238409492;sz=0x0;ord=%5Btimestamp%5D;dc_lat=;dc_rdid=;tag_for_child_directed_treatment=;tfua=;dcmt=text/xml;dc_vast=3"
/>
<video controls>
<source src="http://clips.vorwaerts-gmbh.de/VfE_html5.mp4" type="video/mp4" />
<source src="http://clips.vorwaerts-gmbh.de/VfE.webm" type="video/webm" />
</video>
</body>
<script>
var videoElement = document.querySelector('video')
var urlElement = document.querySelector('[name="vastUrl"]')
var v = new ConcertVast()
function loadVast(url) {
v.loadRemoteVast(url, { timeout: 10000 })
.then(function() {
console.log('loading', url)
console.log('bandwidth:', v.bandwidth())
var bestVideo = v.bestVideo({
height: videoElement.clientHeight,
width: videoElement.clientWidth,
})
console.log('best video', bestVideo.url(), bestVideo.mimeType(), bestVideo.bitrate())
Array.from(videoElement.querySelectorAll('source')).forEach(s => {
s.remove()
})
const vidSource = document.createElement('source')
vidSource.setAttribute('src', bestVideo.url())
vidSource.setAttribute('type', bestVideo.mimeType())
videoElement.appendChild(vidSource)
videoElement.load()
})
.catch(error => {
console.log("Can't load video, you got yourself an error", error)
})
}
loadVast(urlElement.value)
urlElement.addEventListener('blur', e => {
loadVast(urlElement.value)
})
</script>
</html>