forked from videojs/videojs-playlist
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
100 lines (91 loc) · 2.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
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
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>videojs-playlist Demo</title>
<link href="/node_modules/video.js/dist/video-js.css" rel="stylesheet">
<style>
button {
margin: 1em;
width: 10em;
}
.autoadvance-group {
margin: 1em;
}
.autoadvance-group label {
margin: 10px;
}
</style>
</head>
<body>
<video class="video-js vjs-default-skin" controls width="640px" height="360px"></video>
<button class="previous">Previous</button>
<button class="next">Next</button>
<div class="autoadvance-group">
<h4>Auto-advance (in seconds)</h4>
<label><input type="radio" name="autoadvance" value="null" checked> No auto-advance</label>
<label><input type="radio" name="autoadvance" value="0"> 0</label>
<label><input type="radio" name="autoadvance" value="5"> 5</label>
<label><input type="radio" name="autoadvance" value="10"> 10</label>
<label><input type="radio" name="autoadvance" value="30"> 30</label>
</div>
<ul>
<li><a href="/test/">Run unit tests in browser.</a></li>
</ul>
<script src="/node_modules/video.js/dist/video.js"></script>
<script src="/dist/videojs-playlist.js"></script>
<script>
var videoList = [{
sources: [{
src: 'http://media.w3.org/2010/05/sintel/trailer.mp4',
type: 'video/mp4'
}],
poster: 'http://media.w3.org/2010/05/sintel/poster.png'
}, {
sources: [{
src: 'http://media.w3.org/2010/05/bunny/trailer.mp4',
type: 'video/mp4'
}],
poster: 'http://media.w3.org/2010/05/bunny/poster.png'
}, {
sources: [{
src: 'http://vjs.zencdn.net/v/oceans.mp4',
type: 'video/mp4'
}],
poster: 'http://www.videojs.com/img/poster.jpg'
}, {
sources: [{
src: 'http://media.w3.org/2010/05/bunny/movie.mp4',
type: 'video/mp4'
}],
poster: 'http://media.w3.org/2010/05/bunny/poster.png'
}, {
sources: [{
src: 'http://media.w3.org/2010/05/video/movie_300.mp4',
type: 'video/mp4'
}],
poster: 'http://media.w3.org/2010/05/video/poster.png'
}];
var player = videojs(document.querySelector('video'), {
inactivityTimeout: 0
});
try {
// try on ios
player.volume(0);
} catch (e) {}
player.playlist(videoList);
document.querySelector('.previous').addEventListener('click', function() {
player.playlist.previous();
});
document.querySelector('.next').addEventListener('click', function() {
player.playlist.next();
});
Array.prototype.forEach.call(document.querySelectorAll('[name=autoadvance]'), function(el) {
el.addEventListener('click', function() {
var value = document.querySelector('[name=autoadvance]:checked').value;
player.playlist.autoadvance(JSON.parse(value));
});
});
</script>
</body>
</html>