josejuan314 commited on
Commit
938e951
·
verified ·
1 Parent(s): ffa21f7

Add 2 files

Browse files
Files changed (2) hide show
  1. README.md +7 -5
  2. index.html +351 -19
README.md CHANGED
@@ -1,10 +1,12 @@
1
  ---
2
- title: Audiovideoswitch
3
- emoji: 🏢
4
- colorFrom: purple
5
- colorTo: pink
6
  sdk: static
7
  pinned: false
 
 
8
  ---
9
 
10
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
  ---
2
+ title: audiovideoswitch
3
+ emoji: 🐳
4
+ colorFrom: pink
5
+ colorTo: purple
6
  sdk: static
7
  pinned: false
8
+ tags:
9
+ - deepsite
10
  ---
11
 
12
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
index.html CHANGED
@@ -1,19 +1,351 @@
1
- <!doctype html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width" />
6
- <title>My static Space</title>
7
- <link rel="stylesheet" href="style.css" />
8
- </head>
9
- <body>
10
- <div class="card">
11
- <h1>Welcome to your static Space!</h1>
12
- <p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p>
13
- <p>
14
- Also don't forget to check the
15
- <a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.
16
- </p>
17
- </div>
18
- </body>
19
- </html>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="es">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Reproductor Video/Audio</title>
7
+ <script src="https://cdn.tailwindcss.com"></script>
8
+ <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
9
+ <style>
10
+ .switch {
11
+ position: relative;
12
+ display: inline-block;
13
+ width: 60px;
14
+ height: 34px;
15
+ }
16
+
17
+ .switch input {
18
+ opacity: 0;
19
+ width: 0;
20
+ height: 0;
21
+ }
22
+
23
+ .slider {
24
+ position: absolute;
25
+ cursor: pointer;
26
+ top: 0;
27
+ left: 0;
28
+ right: 0;
29
+ bottom: 0;
30
+ background-color: #4f46e5;
31
+ transition: .4s;
32
+ border-radius: 34px;
33
+ }
34
+
35
+ .slider:before {
36
+ position: absolute;
37
+ content: "";
38
+ height: 26px;
39
+ width: 26px;
40
+ left: 4px;
41
+ bottom: 4px;
42
+ background-color: white;
43
+ transition: .4s;
44
+ border-radius: 50%;
45
+ }
46
+
47
+ input:checked + .slider {
48
+ background-color: #10b981;
49
+ }
50
+
51
+ input:checked + .slider:before {
52
+ transform: translateX(26px);
53
+ }
54
+
55
+ .slider-icon {
56
+ position: absolute;
57
+ top: 50%;
58
+ transform: translateY(-50%);
59
+ color: white;
60
+ font-size: 14px;
61
+ }
62
+
63
+ .video-icon {
64
+ left: 8px;
65
+ }
66
+
67
+ .audio-icon {
68
+ right: 8px;
69
+ }
70
+
71
+ #videoContainer {
72
+ transition: all 0.3s ease;
73
+ }
74
+
75
+ #audioContainer {
76
+ transition: all 0.3s ease;
77
+ background: linear-gradient(135deg, #4f46e5 0%, #10b981 100%);
78
+ }
79
+
80
+ .progress-container {
81
+ height: 6px;
82
+ background-color: #e5e7eb;
83
+ border-radius: 3px;
84
+ cursor: pointer;
85
+ }
86
+
87
+ .progress-bar {
88
+ height: 100%;
89
+ background-color: #4f46e5;
90
+ border-radius: 3px;
91
+ width: 0%;
92
+ }
93
+
94
+ .thumbnail {
95
+ width: 100%;
96
+ height: 100%;
97
+ object-fit: cover;
98
+ border-radius: 8px;
99
+ }
100
+
101
+ .audio-visualizer {
102
+ display: flex;
103
+ align-items: flex-end;
104
+ height: 50px;
105
+ gap: 2px;
106
+ }
107
+
108
+ .audio-bar {
109
+ background-color: rgba(255, 255, 255, 0.7);
110
+ width: 4px;
111
+ border-radius: 2px;
112
+ animation: equalize 1s infinite alternate;
113
+ animation-delay: calc(var(--order) * 100ms);
114
+ }
115
+
116
+ @keyframes equalize {
117
+ 0% {
118
+ height: 10%;
119
+ }
120
+ 100% {
121
+ height: calc(var(--height) * 1%);
122
+ }
123
+ }
124
+ </style>
125
+ </head>
126
+ <body class="bg-gray-100 min-h-screen flex items-center justify-center p-4">
127
+ <div class="w-full max-w-2xl bg-white rounded-xl shadow-xl overflow-hidden">
128
+ <!-- Header -->
129
+ <div class="bg-indigo-600 p-4 text-white">
130
+ <h1 class="text-xl font-bold text-center">Reproductor Flexible</h1>
131
+ <p class="text-center text-indigo-100 text-sm">Cambia entre video y audio sin perder la reproducción</p>
132
+ </div>
133
+
134
+ <!-- Main Content -->
135
+ <div class="p-6">
136
+ <!-- Video Container (Visible by default) -->
137
+ <div id="videoContainer" class="mb-6 rounded-lg overflow-hidden relative">
138
+ <video id="mediaPlayer" class="w-full aspect-video bg-black" poster="https://i.imgur.com/3ZQZQ9m.jpg" controls>
139
+ <source id="mediaSource" src="https://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4" type="video/mp4">
140
+ Tu navegador no soporta el elemento de video.
141
+ </video>
142
+ <div id="videoOverlay" class="absolute inset-0 flex items-center justify-center bg-black bg-opacity-30 hidden">
143
+ <button id="playBtn" class="w-16 h-16 rounded-full bg-indigo-600 text-white flex items-center justify-center hover:bg-indigo-700 transition">
144
+ <i class="fas fa-play text-2xl"></i>
145
+ </button>
146
+ </div>
147
+ </div>
148
+
149
+ <!-- Audio Container (Hidden by default) -->
150
+ <div id="audioContainer" class="hidden mb-6 rounded-lg p-6">
151
+ <div class="flex items-center">
152
+ <div class="mr-4">
153
+ <div class="w-16 h-16 rounded-lg overflow-hidden shadow-md">
154
+ <img src="https://i.imgur.com/3ZQZQ9m.jpg" alt="Thumbnail" class="thumbnail">
155
+ </div>
156
+ </div>
157
+ <div class="flex-1">
158
+ <h3 class="text-white font-medium">Big Buck Bunny</h3>
159
+ <p class="text-white text-opacity-80 text-sm">Reproduciendo en modo audio</p>
160
+
161
+ <!-- Audio Visualizer -->
162
+ <div class="audio-visualizer mt-2">
163
+ <div class="audio-bar" style="--height: 30; --order: 1;"></div>
164
+ <div class="audio-bar" style="--height: 60; --order: 2;"></div>
165
+ <div class="audio-bar" style="--height: 40; --order: 3;"></div>
166
+ <div class="audio-bar" style="--height: 80; --order: 4;"></div>
167
+ <div class="audio-bar" style="--height: 50; --order: 5;"></div>
168
+ <div class="audio-bar" style="--height: 70; --order: 6;"></div>
169
+ <div class="audio-bar" style="--height: 30; --order: 7;"></div>
170
+ <div class="audio-bar" style="--height: 90; --order: 8;"></div>
171
+ <div class="audio-bar" style="--height: 60; --order: 9;"></div>
172
+ <div class="audio-bar" style="--height: 40; --order: 10;"></div>
173
+ </div>
174
+ </div>
175
+ </div>
176
+ </div>
177
+
178
+ <!-- Custom Controls -->
179
+ <div class="space-y-4">
180
+ <!-- Progress Bar -->
181
+ <div class="progress-container" id="progressContainer">
182
+ <div class="progress-bar" id="progressBar"></div>
183
+ </div>
184
+
185
+ <!-- Time Display -->
186
+ <div class="flex justify-between text-sm text-gray-600">
187
+ <span id="currentTime">0:00</span>
188
+ <span id="duration">1:00</span>
189
+ </div>
190
+
191
+ <!-- Main Controls -->
192
+ <div class="flex items-center justify-between">
193
+ <!-- Play/Pause Button -->
194
+ <button id="playPauseBtn" class="w-12 h-12 rounded-full bg-indigo-100 text-indigo-600 flex items-center justify-center hover:bg-indigo-200 transition">
195
+ <i class="fas fa-play"></i>
196
+ </button>
197
+
198
+ <!-- Volume Control -->
199
+ <div class="flex items-center space-x-2">
200
+ <i class="fas fa-volume-down text-gray-600"></i>
201
+ <input type="range" id="volumeControl" min="0" max="1" step="0.01" value="1" class="w-24">
202
+ </div>
203
+
204
+ <!-- Mode Switch -->
205
+ <div class="flex items-center space-x-3">
206
+ <span class="text-sm font-medium text-gray-700">Modo:</span>
207
+ <label class="switch">
208
+ <input type="checkbox" id="modeSwitch">
209
+ <span class="slider"></span>
210
+ <span class="slider-icon video-icon"><i class="fas fa-video"></i></span>
211
+ <span class="slider-icon audio-icon"><i class="fas fa-music"></i></span>
212
+ </label>
213
+ </div>
214
+ </div>
215
+ </div>
216
+ </div>
217
+ </div>
218
+
219
+ <script>
220
+ document.addEventListener('DOMContentLoaded', function() {
221
+ // Elements
222
+ const mediaPlayer = document.getElementById('mediaPlayer');
223
+ const videoContainer = document.getElementById('videoContainer');
224
+ const audioContainer = document.getElementById('audioContainer');
225
+ const playPauseBtn = document.getElementById('playPauseBtn');
226
+ const playBtn = document.getElementById('playBtn');
227
+ const progressBar = document.getElementById('progressBar');
228
+ const progressContainer = document.getElementById('progressContainer');
229
+ const currentTimeDisplay = document.getElementById('currentTime');
230
+ const durationDisplay = document.getElementById('duration');
231
+ const volumeControl = document.getElementById('volumeControl');
232
+ const modeSwitch = document.getElementById('modeSwitch');
233
+ const videoOverlay = document.getElementById('videoOverlay');
234
+
235
+ // Initial state
236
+ let isVideoMode = true;
237
+
238
+ // Play/Pause functionality
239
+ function togglePlayPause() {
240
+ if (mediaPlayer.paused) {
241
+ mediaPlayer.play();
242
+ playPauseBtn.innerHTML = '<i class="fas fa-pause"></i>';
243
+ videoOverlay.classList.add('hidden');
244
+ } else {
245
+ mediaPlayer.pause();
246
+ playPauseBtn.innerHTML = '<i class="fas fa-play"></i>';
247
+ if (isVideoMode) videoOverlay.classList.remove('hidden');
248
+ }
249
+ }
250
+
251
+ playPauseBtn.addEventListener('click', togglePlayPause);
252
+ playBtn.addEventListener('click', togglePlayPause);
253
+
254
+ // Update progress bar
255
+ mediaPlayer.addEventListener('timeupdate', function() {
256
+ const progress = (mediaPlayer.currentTime / mediaPlayer.duration) * 100;
257
+ progressBar.style.width = `${progress}%`;
258
+
259
+ // Update time displays
260
+ currentTimeDisplay.textContent = formatTime(mediaPlayer.currentTime);
261
+ if (!isNaN(mediaPlayer.duration)) {
262
+ durationDisplay.textContent = formatTime(mediaPlayer.duration);
263
+ }
264
+ });
265
+
266
+ // Click on progress bar to seek
267
+ progressContainer.addEventListener('click', function(e) {
268
+ const rect = progressContainer.getBoundingClientRect();
269
+ const pos = (e.clientX - rect.left) / rect.width;
270
+ mediaPlayer.currentTime = pos * mediaPlayer.duration;
271
+ });
272
+
273
+ // Volume control
274
+ volumeControl.addEventListener('input', function() {
275
+ mediaPlayer.volume = this.value;
276
+ });
277
+
278
+ // Mode switch
279
+ modeSwitch.addEventListener('change', function() {
280
+ isVideoMode = !isVideoMode;
281
+
282
+ if (isVideoMode) {
283
+ videoContainer.classList.remove('hidden');
284
+ audioContainer.classList.add('hidden');
285
+ if (mediaPlayer.paused) {
286
+ videoOverlay.classList.remove('hidden');
287
+ }
288
+ } else {
289
+ videoContainer.classList.add('hidden');
290
+ audioContainer.classList.remove('hidden');
291
+ videoOverlay.classList.add('hidden');
292
+ }
293
+ });
294
+
295
+ // Format time (seconds to MM:SS)
296
+ function formatTime(seconds) {
297
+ const minutes = Math.floor(seconds / 60);
298
+ const secs = Math.floor(seconds % 60);
299
+ return `${minutes}:${secs < 10 ? '0' : ''}${secs}`;
300
+ }
301
+
302
+ // Update duration when metadata is loaded
303
+ mediaPlayer.addEventListener('loadedmetadata', function() {
304
+ durationDisplay.textContent = formatTime(mediaPlayer.duration);
305
+ });
306
+
307
+ // Show overlay when video ends
308
+ mediaPlayer.addEventListener('ended', function() {
309
+ playPauseBtn.innerHTML = '<i class="fas fa-play"></i>';
310
+ if (isVideoMode) videoOverlay.classList.remove('hidden');
311
+ });
312
+
313
+ // Initialize
314
+ mediaPlayer.volume = volumeControl.value;
315
+
316
+ // Animate audio bars when playing
317
+ mediaPlayer.addEventListener('play', function() {
318
+ const audioBars = document.querySelectorAll('.audio-bar');
319
+ audioBars.forEach(bar => {
320
+ bar.style.animationPlayState = 'running';
321
+ });
322
+ });
323
+
324
+ mediaPlayer.addEventListener('pause', function() {
325
+ const audioBars = document.querySelectorAll('.audio-bar');
326
+ audioBars.forEach(bar => {
327
+ bar.style.animationPlayState = 'paused';
328
+ });
329
+ });
330
+
331
+ // Optional: Replace with your video URL
332
+ function setMediaSource(url, posterUrl) {
333
+ document.getElementById('mediaSource').src = url;
334
+ mediaPlayer.poster = posterUrl || '';
335
+ mediaPlayer.load();
336
+
337
+ // Update thumbnail in audio mode
338
+ if (posterUrl) {
339
+ const audioThumbnail = document.querySelector('#audioContainer img');
340
+ if (audioThumbnail) {
341
+ audioThumbnail.src = posterUrl;
342
+ }
343
+ }
344
+ }
345
+
346
+ // Example of how to set a new video URL (you can call this function when needed)
347
+ // setMediaSource('YOUR_NEW_VIDEO_URL.mp4', 'YOUR_THUMBNAIL_URL.jpg');
348
+ });
349
+ </script>
350
+ <p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=josejuan314/audiovideoswitch" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
351
+ </html>