Skip to content

Commit bedb42e

Browse files
author
Dario Luna
committed
Improve video loading with fallback paths and better error handling
1 parent 1bd756b commit bedb42e

File tree

1 file changed

+48
-6
lines changed

1 file changed

+48
-6
lines changed

index.html

Lines changed: 48 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,18 @@
1818
aspect-ratio: 16 / 9;
1919
background: #000;
2020
}
21-
.carousel-item img,
22-
.carousel-item video {
21+
.carousel-item img {
2322
object-fit: cover;
2423
width: 100%;
2524
height: 100%;
2625
display: block;
2726
}
27+
.carousel-item video {
28+
width: 100%;
29+
height: 100%;
30+
display: block;
31+
background: #000;
32+
}
2833
/* If your video needs rotation, uncomment and adjust:
2934
.carousel-item video.rotate90 {
3035
transform: rotate(90deg);
@@ -69,7 +74,15 @@ <h5>Photo 2</h5>
6974

7075
<!-- Video -->
7176
<div class="carousel-item active">
72-
<video class="d-block w-100" controls playsinline preload="auto" muted>
77+
<video
78+
class="d-block w-100"
79+
controls
80+
playsinline
81+
preload="metadata"
82+
muted
83+
poster=""
84+
style="max-width: 100%; height: auto; min-height: 400px;">
85+
<source src="/jconf-xtech/assets/video.mp4" type="video/mp4" />
7386
<source src="assets/video.mp4" type="video/mp4" />
7487
Your browser does not support HTML5 video.
7588
</video>
@@ -114,23 +127,52 @@ <h5>Photo 3</h5>
114127
videos.forEach(v => v.pause());
115128
});
116129

117-
// Debug video loading issues
130+
// Debug video loading issues and force load
118131
document.addEventListener('DOMContentLoaded', () => {
119132
const video = document.querySelector('video');
120133
if (video) {
134+
// Try to load the video
135+
video.load();
136+
121137
video.addEventListener('error', (e) => {
122138
console.error('Video error:', e);
123-
console.error('Video error details:', video.error);
139+
console.error('Video error code:', video.error?.code);
140+
console.error('Video error message:', video.error?.message);
141+
console.error('Video network state:', video.networkState);
142+
console.error('Video ready state:', video.readyState);
143+
// Try alternative path
144+
if (video.error && video.error.code === 4) {
145+
const source = video.querySelector('source');
146+
if (source && source.src === '/jconf-xtech/assets/video.mp4') {
147+
source.src = 'assets/video.mp4';
148+
video.load();
149+
}
150+
}
124151
});
125152
video.addEventListener('loadstart', () => {
126153
console.log('Video loading started');
127154
});
155+
video.addEventListener('progress', () => {
156+
console.log('Video loading progress:', Math.round((video.buffered.length > 0 ? video.buffered.end(0) / video.duration * 100 : 0)) + '%');
157+
});
128158
video.addEventListener('canplay', () => {
129159
console.log('Video can play');
130160
});
161+
video.addEventListener('canplaythrough', () => {
162+
console.log('Video can play through');
163+
});
131164
video.addEventListener('loadedmetadata', () => {
132-
console.log('Video metadata loaded');
165+
console.log('Video metadata loaded, duration:', video.duration);
166+
});
167+
video.addEventListener('loadeddata', () => {
168+
console.log('Video data loaded');
133169
});
170+
171+
// Log current source
172+
const source = video.querySelector('source');
173+
if (source) {
174+
console.log('Video source:', source.src);
175+
}
134176
}
135177
});
136178
</script>

0 commit comments

Comments
 (0)