-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVideo.php
More file actions
147 lines (118 loc) · 3.5 KB
/
Video.php
File metadata and controls
147 lines (118 loc) · 3.5 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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
<?php
$dir = __DIR__;
$files = glob($dir . "/*.{mp4,webm}", GLOB_BRACE);
sort($files, SORT_NATURAL | SORT_FLAG_CASE);
if (!$files)
die("Keine Video-Dateien gefunden.");
$current = isset($_GET['vid']) ? intval($_GET['vid']) : 0;
$current = max(0, min($current, count($files) - 1));
$self = htmlspecialchars($_SERVER['SCRIPT_NAME'], ENT_QUOTES, 'UTF-8');
?>
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>Bild Viewer</title>
<style>
html,
body {
margin: 0;
height: 100%;
background-color: #666666;
overflow: hidden;
}
.wrapper {
position: fixed;
inset: 0;
display: flex;
justify-content: center;
align-items: center;
overflow: hidden;
}
.inner {
position: relative;
width: 100%;
height: 100%;
display: flex;
justify-content: center;
align-items: center;
overflow: hidden;
}
#video {
max-width: 100%;
max-height: 100%;
}
.arrow {
position: fixed;
top: 50%;
transform: translateY(-50%);
font-size: 48px;
color: #fff;
text-decoration: none;
padding: 8px 12px;
user-select: none;
cursor: pointer;
z-index: 50;
}
.arrow-left {
left: 8px;
}
.arrow-right {
right: 8px;
}
.disabled {
visibility: hidden;
pointer-events: none;
}
@media (max-width: 480px) {
.arrow {
font-size: 36px;
padding: 6px;
}
}
</style>
</head>
<body>
<a class="arrow arrow-left <?= ($current == 0) ? 'disabled' : '' ?>"
href="<?= $self ?>?vid=<?= max(0, $current - 1) ?>" aria-label="Zurück">◀</a>
<div class="wrapper">
<div class="inner">
<video id="vid" controls autoplay style="max-width:100%; max-height:100%;">
<source src="<?= htmlspecialchars(basename($files[$current])) ?>" type="video/mp4">
Dein Browser unterstützt dieses Videoformat nicht.
</video>
</div>
</div>
<a class="arrow arrow-right <?= ($current >= count($files) - 1) ? 'disabled' : '' ?>"
href="<?= $self ?>?vid=<?= min(count($files) - 1, $current + 1) ?>" aria-label="Vor">▶</a>
<script>
const vid = document.getElementById('vid');
const inner = document.querySelector('.inner');
function resizeVideo() {
const containerW = inner.clientWidth;
const containerH = inner.clientHeight;
const videoW = vid.videoWidth;
const videoH = vid.videoHeight;
if (!videoW || !videoH) return;
const scaleX = containerW / videoW;
const scaleY = containerH / videoH;
const scale = Math.min(scaleX, scaleY);
vid.style.width = videoW * scale + 'px';
vid.style.height = videoH * scale + 'px';
}
vid.addEventListener('loadedmetadata', resizeVideo);
window.addEventListener('resize', resizeVideo);
// Pfeiltasten
window.addEventListener('keydown', function (e) {
if (e.key === 'ArrowLeft') {
const left = document.querySelector('.arrow-left:not(.disabled)');
if (left) window.location.href = left.href;
} else if (e.key === 'ArrowRight') {
const right = document.querySelector('.arrow-right:not(.disabled)');
if (right) window.location.href = right.href;
}
});
</script>
</body>
</html>