WEBLEB
Accueil
Éditeur
Connexion
Pro
Français
English
Français
Español
Português
Deutsch
Italiano
हिंदी
Lecteur vidéo brutaliste
144
alejandrokundrah
Ouvrir dans l'éditeur
Publiez votre code
Recommandé
21 August 2024
Carrousel avec traînée et roue
22 November 2024
télécharger la carte d'application
23 April 2025
Générateur de mots de passe par SENAPI
HTML
Copy
Futuristic Video Player
Big Buck Bunny
0:00
/
0:00
Auto
1080p
720p
480p
360p
Off
English
Spanish
French
German
Japanese
Original
English
Spanish
French
German
Japanese
×
Share Video
Facebook
Twitter
WhatsApp
Email
Copy
×
Cast to Device
Living Room TV
Bedroom Tablet
Office Computer
Media Center
×
Live Translation Settings
Translate from:
Auto-detect
English
Spanish
French
German
Japanese
Translate to:
English
Spanish
French
German
Japanese
Apply
CSS
Copy
:root { --primary-color: #00b4ff; --secondary-color: #7a29ff; --background-color: #0f1923; --surface-color: #1a2530; --text-color: #ffffff; --text-secondary-color: #a0a0a0; --accent-color: #ff2970; --overlay-color: rgba(0, 0, 0, 0.7); --tooltip-background: rgba(26, 37, 48, 0.95); --gradient: linear-gradient(45deg, var(--primary-color), var(--secondary-color)); } * { margin: 0; padding: 0; box-sizing: border-box; } body { font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; background-color: var(--background-color); color: var(--text-color); height: 100vh; display: flex; justify-content: center; align-items: center; } .video-container { width: 90%; max-width: 1200px; border-radius: 12px; overflow: hidden; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3); background-color: var(--surface-color); } .video-wrapper { position: relative; width: 100%; height: 0; padding-bottom: 56.25%; /* 16:9 aspect ratio */ overflow: hidden; } video { position: absolute; top: 0; left: 0; width: 100%; height: 100%; object-fit: cover; background-color: #000; } .video-controls { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: linear-gradient(to top, rgba(0, 0, 0, 0.8) 0%, transparent 30%, transparent 70%, rgba(0, 0, 0, 0.8) 100%); opacity: 0; transition: opacity 0.3s ease; display: flex; flex-direction: column; justify-content: space-between; padding: 20px; } .video-wrapper:hover .video-controls, .video-controls.active { opacity: 1; } .top-controls, .bottom-controls { display: flex; justify-content: space-between; align-items: center; z-index: 2; } .top-controls { justify-content: space-between; } .title { font-size: 18px; font-weight: 600; text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5); } .center-controls { display: flex; justify-content: center; align-items: center; gap: 20px; z-index: 2; } .control-btn { background: none; border: none; color: var(--text-color); font-size: 16px; cursor: pointer; width: 40px; height: 40px; border-radius: 50%; display: flex; justify-content: center; align-items: center; transition: all 0.2s ease; } .center-controls .control-btn { font-size: 20px; } #play-pause-btn { background-color: var(--primary-color); width: 50px; height: 50px; } .control-btn:hover { background-color: rgba(255, 255, 255, 0.2); } #play-pause-btn:hover { background-color: var(--secondary-color); transform: scale(1.05); } .progress-container { position: relative; width: 100%; height: 5px; background-color: rgba(255, 255, 255, 0.2); border-radius: 5px; cursor: pointer; margin-bottom: 10px; } .buffered-progress, .playback-progress { position: absolute; height: 100%; border-radius: 5px; left: 0; } .buffered-progress { background-color: rgba(255, 255, 255, 0.3); width: 70%; /* Example value */ } .playback-progress { background: var(--gradient); width: 30%; /* Example value */ } .progress-slider { position: absolute; width: 100%; height: 100%; opacity: 0; cursor: pointer; } .time-display { color: var(--text-secondary-color); font-size: 14px; margin-left: 15px; } .controls-bar { display: flex; justify-content: space-between; width: 100%; } .left-controls, .right-controls { display: flex; align-items: center; gap: 15px; } .volume-slider-container { width: 0; overflow: hidden; transition: width 0.3s ease; } .volume-slider-container.active { width: 80px; } .volume-slider { width: 80px; height: 5px; -webkit-appearance: none; background-color: rgba(255, 255, 255, 0.2); border-radius: 5px; outline: none; } .volume-slider::-webkit-slider-thumb { -webkit-appearance: none; width: 12px; height: 12px; border-radius: 50%; background: var(--primary-color); cursor: pointer; } .tooltip { position: relative; } .tooltip::after { content: attr(data-tooltip); position: absolute; bottom: 110%; left: 50%; transform: translateX(-50%); white-space: nowrap; background-color: var(--tooltip-background); color: var(--text-color); padding: 4px 8px; border-radius: 4px; font-size: 12px; pointer-events: none; opacity: 0; transition: opacity 0.2s ease; } .tooltip:hover::after { opacity: 1; } .dropdown { position: relative; } .dropdown-toggle { background: none; border: none; color: var(--text-color); cursor: pointer; width: 40px; height: 40px; border-radius: 50%; display: flex; justify-content: center; align-items: center; transition: all 0.2s ease; } .dropdown-toggle:hover { background-color: rgba(255, 255, 255, 0.2); } .dropdown-menu { position: absolute; bottom: 100%; right: 0; background-color: var(--tooltip-background); border-radius: 8px; padding: 8px 0; min-width: 150px; opacity: 0; visibility: hidden; transform: translateY(10px); transition: all 0.3s ease; box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3); z-index: 10; margin-bottom: 10px; } .dropdown.active .dropdown-menu { opacity: 1; visibility: visible; transform: translateY(0); } .dropdown-item { padding: 8px 16px; cursor: pointer; transition: background-color 0.2s ease; color: var(--text-secondary-color); } .dropdown-item:hover { background-color: rgba(255, 255, 255, 0.1); color: var(--text-color); } .dropdown-item.active { color: var(--primary-color); font-weight: 500; } /* Modal Styling */ .modal { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: var(--overlay-color); z-index: 1000; justify-content: center; align-items: center; } .modal.active { display: flex; } .modal-content { background-color: var(--surface-color); border-radius: 12px; padding: 24px; width: 90%; max-width: 500px; position: relative; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4); } .close-modal { position: absolute; top: 15px; right: 20px; font-size: 24px; cursor: pointer; color: var(--text-secondary-color); transition: color 0.2s ease; } .close-modal:hover { color: var(--text-color); } .modal-content h2 { margin-bottom: 20px; color: var(--text-color); font-weight: 500; } /* Share Modal */ .share-options { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 20px; } .share-option { background-color: rgba(255, 255, 255, 0.1); border: none; color: var(--text-color); padding: 12px; border-radius: 8px; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 8px; transition: all 0.2s ease; } .share-option:hover { background-color: rgba(255, 255, 255, 0.2); } .share-link { display: flex; margin-top: 15px; } #share-url { flex: 1; padding: 10px 15px; border: 1px solid rgba(255, 255, 255, 0.2); background-color: rgba(255, 255, 255, 0.1); color: var(--text-color); border-radius: 6px 0 0 6px; outline: none; } #copy-link-btn { background-color: var(--primary-color); color: var(--text-color); border: none; padding: 0 15px; border-radius: 0 6px 6px 0; cursor: pointer; transition: background-color 0.2s ease; } #copy-link-btn:hover { background-color: var(--secondary-color); } /* Cast Modal */ .cast-devices { display: grid; gap: 12px; } .cast-device { display: flex; align-items: center; gap: 12px; padding: 12px; background-color: rgba(255, 255, 255, 0.1); border-radius: 8px; cursor: pointer; transition: all 0.2s ease; } .cast-device:hover { background-color: rgba(255, 255, 255, 0.2); } .cast-device i { font-size: 20px; color: var(--primary-color); } /* Translation Modal */ .translation-options { display: grid; gap: 15px; margin-bottom: 20px; } .translation-option { display: flex; flex-direction: column; gap: 8px; } .translation-option label { color: var(--text-secondary-color); font-size: 14px; } .translation-option select { padding: 10px; background-color: rgba(255, 255, 255, 0.1); border: 1px solid rgba(255, 255, 255, 0.2); border-radius: 6px; color: var(--text-color); outline: none; } #apply-translation-btn { background-color: var(--primary-color); color: var(--text-color); border: none; padding: 12px; border-radius: 6px; cursor: pointer; width: 100%; transition: background-color 0.2s ease; margin-top: 10px; } #apply-translation-btn:hover { background-color: var(--secondary-color); } /* Responsive adjustments */ @media (max-width: 768px) { .video-controls { padding: 15px; } .title { font-size: 16px; } .control-btn { width: 36px; height: 36px; font-size: 14px; } #play-pause-btn { width: 46px; height: 46px; } .right-controls { gap: 10px; } .share-options { grid-template-columns: 1fr; } } @media (max-width: 480px) { .video-controls { padding: 10px; } .top-controls .right-controls, .bottom-controls .right-controls { gap: 8px; } .control-btn { width: 32px; height: 32px; font-size: 12px; } #play-pause-btn { width: 42px; height: 42px; } .time-display { font-size: 12px; } .modal-content { padding: 15px; } }
JS
Copy
document.addEventListener('DOMContentLoaded', () => { // Elements const videoContainer = document.querySelector('.video-container'); const videoElement = document.getElementById('video'); const videoControls = document.querySelector('.video-controls'); const playPauseBtn = document.getElementById('play-pause-btn'); const rewindBtn = document.getElementById('rewind-btn'); const forwardBtn = document.getElementById('forward-btn'); const volumeBtn = document.getElementById('volume-btn'); const volumeSlider = document.querySelector('.volume-slider'); const volumeContainer = document.querySelector('.volume-slider-container'); const fullscreenBtn = document.getElementById('fullscreen-btn'); const currentTimeDisplay = document.getElementById('current-time'); const durationDisplay = document.getElementById('duration'); const progressContainer = document.querySelector('.progress-container'); const bufferedProgress = document.querySelector('.buffered-progress'); const playbackProgress = document.querySelector('.playback-progress'); const progressSlider = document.querySelector('.progress-slider'); const shareBtn = document.getElementById('share-btn'); const downloadBtn = document.getElementById('download-btn'); const castBtn = document.getElementById('cast-btn'); const translateBtn = document.getElementById('translate-btn'); const dropdowns = document.querySelectorAll('.dropdown'); // Modals const shareModal = document.getElementById('share-modal'); const castModal = document.getElementById('cast-modal'); const translateModal = document.getElementById('translate-modal'); const closeModalBtns = document.querySelectorAll('.close-modal'); const copyLinkBtn = document.getElementById('copy-link-btn'); const shareUrl = document.getElementById('share-url'); const castDevices = document.querySelectorAll('.cast-device'); const applyTranslationBtn = document.getElementById('apply-translation-btn'); // State variables let isPlaying = false; let isMuted = false; let previousVolume = 1; let hideControlsTimeout; let currentSubtitle = 'off'; let currentLanguage = 'original'; let currentQuality = 'auto'; let isTranslating = false; // Initialize video player const initPlayer = () => { // Set initial volume videoElement.volume = volumeSlider.value; // Update video duration when metadata is loaded videoElement.addEventListener('loadedmetadata', () => { progressSlider.max = videoElement.duration; durationDisplay.textContent = formatTime(videoElement.duration); }); // Auto-hide controls after 3 seconds of inactivity videoContainer.addEventListener('mousemove', () => { showControls(); resetHideControlsTimer(); }); videoContainer.addEventListener('mouseleave', () => { if (isPlaying) { hideControlsTimeout = setTimeout(() => { hideControls(); }, 3000); } }); // Prevent controls from hiding when interacting with them videoControls.addEventListener('mouseenter', () => { clearTimeout(hideControlsTimeout); }); // Load subtitles (mock implementation) loadSubtitles(); // Update buffered progress (mock implementation) setInterval(updateBufferedProgress, 1000); // Listen for video end videoElement.addEventListener('ended', () => { isPlaying = false; playPauseBtn.innerHTML = '<i class="fas fa-play"></i>'; showControls(); }); }; // Play/Pause functionality const togglePlayPause = () => { if (videoElement.paused) { videoElement.play(); isPlaying = true; playPauseBtn.innerHTML = '<i class="fas fa-pause"></i>'; resetHideControlsTimer(); } else { videoElement.pause(); isPlaying = false; playPauseBtn.innerHTML = '<i class="fas fa-play"></i>'; showControls(); } }; // Show video controls const showControls = () => { videoControls.classList.add('active'); }; // Hide video controls const hideControls = () => { if (!videoElement.paused && !videoControls.matches(':hover')) { videoControls.classList.remove('active'); } }; // Reset timer for hiding controls const resetHideControlsTimer = () => { clearTimeout(hideControlsTimeout); if (isPlaying) { hideControlsTimeout = setTimeout(() => { hideControls(); }, 3000); } }; // Format time to MM:SS const formatTime = (timeInSeconds) => { const minutes = Math.floor(timeInSeconds / 60); const seconds = Math.floor(timeInSeconds % 60); return `${minutes}:${seconds.toString().padStart(2, '0')}`; }; // Update progress bar and time display const updateProgress = () => { if (!videoElement.paused) { const currentTime = videoElement.currentTime; const duration = videoElement.duration; // Update progress bar const progressPercentage = (currentTime / duration) * 100; playbackProgress.style.width = `${progressPercentage}%`; progressSlider.value = currentTime; // Update time display currentTimeDisplay.textContent = formatTime(currentTime); } requestAnimationFrame(updateProgress); }; // Update buffered progress (mock implementation) const updateBufferedProgress = () => { if (videoElement.buffered.length > 0) { const bufferedEnd = videoElement.buffered.end(videoElement.buffered.length - 1); const duration = videoElement.duration; const bufferedPercentage = (bufferedEnd / duration) * 100; bufferedProgress.style.width = `${bufferedPercentage}%`; } }; // Seek video const seekVideo = (e) => { const seekTime = e.target.value; videoElement.currentTime = seekTime; playbackProgress.style.width = `${(seekTime / videoElement.duration) * 100}%`; currentTimeDisplay.textContent = formatTime(seekTime); }; // Toggle mute const toggleMute = () => { if (videoElement.volume === 0 || videoElement.muted) { videoElement.muted = false; videoElement.volume = previousVolume; volumeSlider.value = previousVolume; volumeBtn.innerHTML = previousVolume > 0.5 ? '<i class="fas fa-volume-up"></i>' : '<i class="fas fa-volume-down"></i>'; } else { previousVolume = videoElement.volume; videoElement.volume = 0; videoElement.muted = true; volumeSlider.value = 0; volumeBtn.innerHTML = '<i class="fas fa-volume-mute"></i>'; } }; // Change volume const changeVolume = (e) => { const volume = e.target.value; videoElement.volume = volume; videoElement.muted = volume === 0; if (volume > 0) { volumeBtn.innerHTML = volume > 0.5 ? '<i class="fas fa-volume-up"></i>' : '<i class="fas fa-volume-down"></i>'; } else { volumeBtn.innerHTML = '<i class="fas fa-volume-mute"></i>'; } }; // Toggle fullscreen const toggleFullscreen = () => { if (!document.fullscreenElement) { if (videoContainer.requestFullscreen) { videoContainer.requestFullscreen(); } else if (videoContainer.webkitRequestFullscreen) { videoContainer.webkitRequestFullscreen(); } else if (videoContainer.msRequestFullscreen) { videoContainer.msRequestFullscreen(); } fullscreenBtn.innerHTML = '<i class="fas fa-compress"></i>'; fullscreenBtn.setAttribute('data-tooltip', 'Exit Fullscreen'); } else { if (document.exitFullscreen) { document.exitFullscreen(); } else if (document.webkitExitFullscreen) { document.webkitExitFullscreen(); } else if (document.msExitFullscreen) { document.msExitFullscreen(); } fullscreenBtn.innerHTML = '<i class="fas fa-expand"></i>'; fullscreenBtn.setAttribute('data-tooltip', 'Fullscreen'); } }; // Forward/Rewind const skipForward = () => { videoElement.currentTime = Math.min(videoElement.currentTime + 10, videoElement.duration); }; const skipBackward = () => { videoElement.currentTime = Math.max(videoElement.currentTime - 10, 0); }; // Toggle dropdown menus const toggleDropdown = (dropdown) => { // Close other dropdowns dropdowns.forEach(d => { if (d !== dropdown && d.classList.contains('active')) { d.classList.remove('active'); } }); dropdown.classList.toggle('active'); }; // Toggle volume slider visibility const toggleVolumeSlider = () => { volumeContainer.classList.toggle('active'); }; // Show modal const showModal = (modal) => { modal.classList.add('active'); }; // Hide modal const hideModal = (modal) => { modal.classList.remove('active'); }; // Load subtitles (mock implementation) const loadSubtitles = () => { console.log('Loading subtitles...'); // In a real implementation, this would load subtitle tracks }; // Change video quality (mock implementation) const changeQuality = (quality) => { console.log(`Changing quality to: ${quality}`); currentQuality = quality; // Update UI to show selected quality document.querySelectorAll('[data-quality]').forEach(item => { item.classList.toggle('active', item.dataset.quality === quality); }); // In a real implementation, this would change video source or use adaptive streaming }; // Change subtitle (mock implementation) const changeSubtitle = (subtitle) => { console.log(`Changing subtitle to: ${subtitle}`); currentSubtitle = subtitle; // Update UI to show selected subtitle document.querySelectorAll('[data-subtitle]').forEach(item => { item.classList.toggle('active', item.dataset.subtitle === subtitle); }); // In a real implementation, this would enable/disable subtitle tracks }; // Change audio language (mock implementation) const changeLanguage = (language) => { console.log(`Changing audio language to: ${language}`); currentLanguage = language; // Update UI to show selected language document.querySelectorAll('[data-language]').forEach(item => { item.classList.toggle('active', item.dataset.language === language); }); // In a real implementation, this would change audio tracks }; // Apply translation settings (mock implementation) const applyTranslation = () => { const sourceLanguage = document.getElementById('translation-source').value; const targetLanguage = document.getElementById('translation-target').value; console.log(`Applying translation from ${sourceLanguage} to ${targetLanguage}`); isTranslating = true; // In a real implementation, this would apply real-time translation hideModal(translateModal); }; // Copy share link const copyShareLink = () => { shareUrl.select(); document.execCommand('copy'); // Show success feedback copyLinkBtn.textContent = 'Copied!'; setTimeout(() => { copyLinkBtn.textContent = 'Copy'; }, 2000); }; // Mock cast to device const castToDevice = (deviceName) => { console.log(`Casting to device: ${deviceName}`); // Show success feedback alert(`Started casting to ${deviceName}`); hideModal(castModal); }; // Add event listeners playPauseBtn.addEventListener('click', togglePlayPause); videoElement.addEventListener('click', togglePlayPause); rewindBtn.addEventListener('click', skipBackward); forwardBtn.addEventListener('click', skipForward); volumeBtn.addEventListener('click', toggleMute); volumeBtn.addEventListener('mouseenter', toggleVolumeSlider); volumeContainer.addEventListener('mouseleave', toggleVolumeSlider); volumeSlider.addEventListener('input', changeVolume); fullscreenBtn.addEventListener('click', toggleFullscreen); progressSlider.addEventListener('input', seekVideo); // Keyboard shortcuts document.addEventListener('keydown', (e) => { if (e.target.tagName.toLowerCase() === 'input') return; switch (e.key.toLowerCase()) { case ' ': case 'k': togglePlayPause(); break; case 'f': toggleFullscreen(); break; case 'm': toggleMute(); break; case 'arrowright': skipForward(); break; case 'arrowleft': skipBackward(); break; case 'arrowup': videoElement.volume = Math.min(videoElement.volume + 0.1, 1); volumeSlider.value = videoElement.volume; if (videoElement.muted) toggleMute(); break; case 'arrowdown': videoElement.volume = Math.max(videoElement.volume - 0.1, 0); volumeSlider.value = videoElement.volume; if (videoElement.volume === 0) { videoElement.muted = true; volumeBtn.innerHTML = '<i class="fas fa-volume-mute"></i>'; } break; } }); // Modal event listeners shareBtn.addEventListener('click', () => showModal(shareModal)); castBtn.addEventListener('click', () => showModal(castModal)); translateBtn.addEventListener('click', () => showModal(translateModal)); closeModalBtns.forEach(btn => { btn.addEventListener('click', () => { const modal = btn.closest('.modal'); hideModal(modal); }); }); // Close modal when clicking outside content document.querySelectorAll('.modal').forEach(modal => { modal.addEventListener('click', (e) => { if (e.target === modal) { hideModal(modal); } }); }); // Copy share link copyLinkBtn.addEventListener('click', copyShareLink); // Cast device selection castDevices.forEach(device => { device.addEventListener('click', () => { const deviceName = device.querySelector('span').textContent; castToDevice(deviceName); }); }); // Apply translation applyTranslationBtn.addEventListener('click', applyTranslation); // Dropdown toggles document.querySelectorAll('.dropdown-toggle').forEach(toggle => { toggle.addEventListener('click', () => { const dropdown = toggle.closest('.dropdown'); toggleDropdown(dropdown); }); }); // Quality selection document.querySelectorAll('[data-quality]').forEach(item => { item.addEventListener('click', () => { const quality = item.dataset.quality; changeQuality(quality); // Close dropdown const dropdown = item.closest('.dropdown'); dropdown.classList.remove('active'); }); }); // Subtitle selection document.querySelectorAll('[data-subtitle]').forEach(item => { item.addEventListener('click', () => { const subtitle = item.dataset.subtitle; changeSubtitle(subtitle); // Close dropdown const dropdown = item.closest('.dropdown'); dropdown.classList.remove('active'); }); }); // Language selection document.querySelectorAll('[data-language]').forEach(item => { item.addEventListener('click', () => { const language = item.dataset.language; changeLanguage(language); // Close dropdown const dropdown = item.closest('.dropdown'); dropdown.classList.remove('active'); }); }); // Download video (mock implementation) downloadBtn.addEventListener('click', () => { alert('Download started. This is a mock implementation.'); }); // Initialize progress updates requestAnimationFrame(updateProgress); // Initialize player initPlayer(); });