Spaces:
Running
Running
Video is not playing sometime devices at all just a grey screen - Follow Up Deployment
Browse files- index.html +40 -8
index.html
CHANGED
@@ -59,9 +59,15 @@
|
|
59 |
|
60 |
<!-- Video Background -->
|
61 |
<div class="fixed inset-0 -z-10 overflow-hidden">
|
62 |
-
<
|
|
|
|
|
|
|
|
|
|
|
|
|
63 |
<source src="https://huggingface.co/spaces/akhaliq/nexusrobotics/resolve/main/Video_of_Robot_Washing_Dishes.mp4" type="video/mp4">
|
64 |
-
<
|
65 |
</video>
|
66 |
<div class="absolute inset-0 bg-black/30"></div>
|
67 |
<button id="soundToggle" class="absolute bottom-4 right-4 bg-white/20 hover:bg-white/30 rounded-full p-3 backdrop-blur-sm transition-all">
|
@@ -122,23 +128,49 @@
|
|
122 |
</section>
|
123 |
|
124 |
<script>
|
125 |
-
//
|
126 |
document.addEventListener('DOMContentLoaded', function() {
|
127 |
-
const video = document.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
128 |
const playPromise = video.play();
|
129 |
|
130 |
if (playPromise !== undefined) {
|
131 |
-
playPromise.
|
|
|
|
|
|
|
|
|
132 |
video.style.display = 'none';
|
133 |
-
|
134 |
-
if (fallbackImg) fallbackImg.style.display = 'block';
|
135 |
});
|
136 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
137 |
});
|
138 |
|
139 |
// Sound toggle functionality
|
140 |
const soundToggle = document.getElementById('soundToggle');
|
141 |
-
const video = document.
|
142 |
|
143 |
soundToggle.addEventListener('click', () => {
|
144 |
video.muted = !video.muted;
|
|
|
59 |
|
60 |
<!-- Video Background -->
|
61 |
<div class="fixed inset-0 -z-10 overflow-hidden">
|
62 |
+
<div id="videoFallback" class="hidden w-full h-full bg-gradient-to-br from-gray-800 to-gray-900 flex items-center justify-center">
|
63 |
+
<div class="text-center">
|
64 |
+
<i class="fas fa-robot text-6xl text-white/50 mb-4"></i>
|
65 |
+
<p class="text-white/70 text-xl">Loading Nexus Robotics Experience</p>
|
66 |
+
</div>
|
67 |
+
</div>
|
68 |
+
<video id="bgVideo" autoplay loop playsinline muted class="w-full h-full object-cover">
|
69 |
<source src="https://huggingface.co/spaces/akhaliq/nexusrobotics/resolve/main/Video_of_Robot_Washing_Dishes.mp4" type="video/mp4">
|
70 |
+
<source src="https://huggingface.co/spaces/akhaliq/nexusrobotics/resolve/main/Video_of_Robot_Washing_Dishes.webm" type="video/webm">
|
71 |
</video>
|
72 |
<div class="absolute inset-0 bg-black/30"></div>
|
73 |
<button id="soundToggle" class="absolute bottom-4 right-4 bg-white/20 hover:bg-white/30 rounded-full p-3 backdrop-blur-sm transition-all">
|
|
|
128 |
</section>
|
129 |
|
130 |
<script>
|
131 |
+
// Enhanced video handling
|
132 |
document.addEventListener('DOMContentLoaded', function() {
|
133 |
+
const video = document.getElementById('bgVideo');
|
134 |
+
const fallback = document.getElementById('videoFallback');
|
135 |
+
|
136 |
+
// Show loading state initially
|
137 |
+
fallback.classList.remove('hidden');
|
138 |
+
|
139 |
+
// Check if video can play
|
140 |
+
const canPlay = video.canPlayType('video/mp4') || video.canPlayType('video/webm');
|
141 |
+
|
142 |
+
if (!canPlay) {
|
143 |
+
// No video support at all
|
144 |
+
video.style.display = 'none';
|
145 |
+
return;
|
146 |
+
}
|
147 |
+
|
148 |
+
// Try to play video
|
149 |
const playPromise = video.play();
|
150 |
|
151 |
if (playPromise !== undefined) {
|
152 |
+
playPromise.then(() => {
|
153 |
+
// Video playing successfully
|
154 |
+
fallback.classList.add('hidden');
|
155 |
+
}).catch(error => {
|
156 |
+
// Video failed to play
|
157 |
video.style.display = 'none';
|
158 |
+
fallback.classList.remove('hidden');
|
|
|
159 |
});
|
160 |
}
|
161 |
+
|
162 |
+
// Fallback if video doesn't load within 5 seconds
|
163 |
+
setTimeout(() => {
|
164 |
+
if (video.readyState < 3) { // 3 = HAVE_FUTURE_DATA
|
165 |
+
video.style.display = 'none';
|
166 |
+
fallback.classList.remove('hidden');
|
167 |
+
}
|
168 |
+
}, 5000);
|
169 |
});
|
170 |
|
171 |
// Sound toggle functionality
|
172 |
const soundToggle = document.getElementById('soundToggle');
|
173 |
+
const video = document.getElementById('bgVideo');
|
174 |
|
175 |
soundToggle.addEventListener('click', () => {
|
176 |
video.muted = !video.muted;
|