-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshorts.html
More file actions
177 lines (150 loc) · 4.77 KB
/
shorts.html
File metadata and controls
177 lines (150 loc) · 4.77 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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Video Gallery</title>
<style>
body, html {
margin: 0;
padding: 0;
width: 100%;
height: 100%;
overflow: hidden;
background-color: #000;
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}
.slider-container {
width: 100%;
height: 100%;
display: flex;
transition: transform 0.5s ease-in-out;
}
.slide {
min-width: 100%;
height: 100%;
position: relative;
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
}
.player {
width: 50vh;
height: 80vh;
max-width: 100%;
max-height: 100%;
border: none;
}
.video-title {
color: #fff;
position: absolute;
bottom: 20px;
left: 20px;
font-size: 1.5em;
text-shadow: 2px 2px 4px rgba(0,0,0,0.7);
}
.nav-arrow {
position: absolute;
top: 50%;
transform: translateY(-50%);
background-color: rgba(0,0,0,0.5);
color: #fff;
border: none;
padding: 15px;
cursor: pointer;
font-size: 2em;
z-index: 100;
user-select: none;
transition: background-color 0.3s;
}
.nav-arrow:hover {
background-color: rgba(0,0,0,0.8);
}
#prevBtn {
left: 10px;
}
#nextBtn {
right: 10px;
}
</style>
</head>
<body>
<div class="slider-container" id="slider">
<!-- Video data will be populated by JavaScript -->
</div>
<button class="nav-arrow" id="prevBtn">❮</button>
<button class="nav-arrow" id="nextBtn">❯</button>
<!-- Load the YouTube IFrame Player API -->
<script src="https://www.youtube.com/iframe_api"></script>
<script>
const slider = document.getElementById('slider');
const prevBtn = document.getElementById('prevBtn');
const nextBtn = document.getElementById('nextBtn');
const videos = [
{ id: 'TfCP-e0-oLA', title: 'English Intro (English)' },
{ id: '1DGNtm38x3E', title: 'Spanish Intro (Spanish)' },
{ id: 'rqZWbO1QFvk', title: 'French Intro (French)' },
{ id: 'acM0LBRhANY', title: 'English Teacher Philosophy (English)' },
{ id: 'SzMZXwIZ8EY', title: 'Spanish Teacher Philosophy (Spanish)' },
{ id: 'oKHUXur8neQ', title: 'French Teacher Philosophy (French)' },
{ id: '3_XBqRBQkZY', title: 'English Classroom (English)' },
{ id: 'zjz1_JFI3OY', title: 'Spanish Classroom (Spanish)' },
{ id: 'lZeuHbrcYE0', title: 'French Classroom (French)' }
];
let players = [];
let currentIndex = 0;
// 1. Create the HTML structure for slides
videos.forEach((video, index) => {
const slide = document.createElement('div');
slide.className = 'slide';
const playerDiv = document.createElement('div');
playerDiv.className = 'player';
playerDiv.id = `player-${index}`;
const titleDiv = document.createElement('div');
titleDiv.className = 'video-title';
titleDiv.textContent = video.title;
slide.appendChild(playerDiv);
slide.appendChild(titleDiv);
slider.appendChild(slide);
});
const slides = document.querySelectorAll('.slide');
// 2. This function creates an <iframe> (and YouTube player)
// after the API code downloads.
function onYouTubeIframeAPIReady() {
videos.forEach((video, index) => {
players[index] = new YT.Player(`player-${index}`, {
height: '100%',
width: '100%',
videoId: video.id,
playerVars: {
'playsinline': 1,
'rel': 0 // Do not show related videos
}
});
});
}
// 3. The API will call this function when the video player is ready.
function goToSlide(newIndex) {
// Stop the video that is currently active
if (players[currentIndex] && typeof players[currentIndex].stopVideo === 'function') {
players[currentIndex].stopVideo();
}
// Wrap the index if it goes out of bounds
if (newIndex < 0) {
newIndex = slides.length - 1;
} else if (newIndex >= slides.length) {
newIndex = 0;
}
currentIndex = newIndex;
slider.style.transform = `translateX(-${currentIndex * 100}%)`;
}
prevBtn.addEventListener('click', () => {
goToSlide(currentIndex - 1);
});
nextBtn.addEventListener('click', () => {
goToSlide(currentIndex + 1);
});
</script>
</body>
</html>