-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy pathschedule.html
More file actions
116 lines (102 loc) · 4.19 KB
/
Copy pathschedule.html
File metadata and controls
116 lines (102 loc) · 4.19 KB
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Cloudinary Video Player - Schedule</title>
<link href="https://res.cloudinary.com/cloudinary-marketing/image/upload/f_auto,q_auto/c_scale,w_32/v1597183771/creative_staging/cloudinary_internal/Website/Brand%20Updates/Favicon/cloudinary_web_favicon_192x192.png" rel="icon" type="image/png">
<!-- Bootstrap -->
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<script type="text/javascript" src="./scripts.js"></script>
<script type="text/javascript">
(function () {
var DAY_NAMES = ['sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday'];
var currentPlayer = null;
function getScheduleForImageMode() {
var now = new Date();
var today = now.getDay();
var slots = [];
for (var d = 0; d < 7; d++) {
if (d !== today) {
slots.push({ day: DAY_NAMES[d], start: '00:00', duration: 24 });
}
}
return slots;
}
function getScheduleForPlayerMode() {
var now = new Date();
var today = now.getDay();
return [{ day: DAY_NAMES[today], start: '00:00', duration: 24 }];
}
function loadPlayerWithMode(showPlayer) {
if (currentPlayer && typeof currentPlayer.dispose === 'function') {
currentPlayer.dispose();
}
var container = document.getElementById('player-container');
container.innerHTML = '<video id="player" playsinline controls muted class="cld-video-player cld-fluid" width="500"></video>';
var scheduleLabel = document.getElementById('schedule-label');
scheduleLabel.textContent = showPlayer
? 'Schedule: Today 00:00-23:59 (player visible)'
: 'Schedule: All days except today (poster visible)';
var schedule = showPlayer ? getScheduleForPlayerMode() : getScheduleForImageMode();
var options = {
cloudName: 'demo',
publicId: 'sea_turtle',
schedule: { weekly: schedule }
};
currentPlayer = cloudinary.videoPlayer('player', options);
if (currentPlayer && typeof currentPlayer.then === 'function') {
currentPlayer.then(function (player) { currentPlayer = player; });
}
}
window.addEventListener('load', function () {
document.getElementById('btn-image').addEventListener('click', function () { loadPlayerWithMode(false); });
document.getElementById('btn-player').addEventListener('click', function () { loadPlayerWithMode(true); });
loadPlayerWithMode(false);
});
})();
</script>
</head>
<body>
<div class="container p-4 col-12 col-md-9 col-xl-6">
<nav class="nav mb-2">
<a href="./index.html"><< Back to examples index</a>
</nav>
<h1>Cloudinary Video Player</h1>
<h3 class="mb-4">Schedule (Weekly Time Slots)</h3>
<p class="mb-4">
Video plays only during configured time slots. Outside schedule, a poster image is shown.
Call <code>loadPlayer()</code> on the stub to load the player on demand (e.g. on click).
</p>
<div class="mb-3">
<label class="mr-2">Mode:</label>
<button type="button" id="btn-image" class="btn btn-sm btn-outline-primary mr-1">Show poster (image)</button>
<button type="button" id="btn-player" class="btn btn-sm btn-outline-primary">Show player</button>
</div>
<h4 class="mb-2" id="schedule-label">Schedule</h4>
<div id="player-container">
<video
id="player"
playsinline
controls
muted
class="cld-video-player cld-fluid"
width="500">
</video>
</div>
<h3 class="mt-4">Example Code:</h3>
<pre><code class="language-javascript">
cloudinary.videoPlayer('player', {
cloudName: 'demo',
publicId: 'sea_turtle',
schedule: {
weekly: [
{ day: 'monday', start: '09:00', duration: 8 },
{ day: 'tuesday', start: '09:00', duration: 8 }
]
}
});
</code></pre>
</div>
</body>
</html>