|
| 1 | +const videos = [ |
| 2 | + { |
| 3 | + title: 'How to Install Visual Studio Code on Windows 11 (VS Code) (2024)', |
| 4 | + src: 'videos/How Install Visual Studio Code on Windows 11 (VS Code) (2024).mp4', |
| 5 | + thumbnail: 'thumbnails/vscode.jpeg', |
| 6 | + }, |
| 7 | + // You can add more videos here if needed |
| 8 | +]; |
| 9 | + |
| 10 | +const videoContainer = document.getElementById('video-container'); |
| 11 | + |
| 12 | +function loadVideos() { |
| 13 | + videos.forEach(video => { |
| 14 | + const videoElement = document.createElement('div'); |
| 15 | + videoElement.className = 'video'; |
| 16 | + videoElement.innerHTML = ` |
| 17 | + <img src="${video.thumbnail}" alt="${video.title}" onclick="playVideo('${video.src}')"> |
| 18 | + <h3>${video.title}</h3> |
| 19 | + `; |
| 20 | + videoContainer.appendChild(videoElement); |
| 21 | + }); |
| 22 | +} |
| 23 | + |
| 24 | +function playVideo(src) { |
| 25 | + document.getElementById('video-source').src = src; |
| 26 | + document.getElementById('video-element').load(); |
| 27 | + document.getElementById('video-player').style.display = 'block'; |
| 28 | +} |
| 29 | + |
| 30 | +function closePlayer() { |
| 31 | + document.getElementById('video-player').style.display = 'none'; |
| 32 | +} |
| 33 | + |
| 34 | +document.getElementById('search').addEventListener('input', function() { |
| 35 | + const query = this.value.toLowerCase(); |
| 36 | + const filteredVideos = videos.filter(video => video.title.toLowerCase().includes(query)); |
| 37 | + videoContainer.innerHTML = ''; |
| 38 | + filteredVideos.forEach(video => { |
| 39 | + const videoElement = document.createElement('div'); |
| 40 | + videoElement.className = 'video'; |
| 41 | + videoElement.innerHTML = ` |
| 42 | + <img src="${video.thumbnail}" alt="${video.title}" onclick="playVideo('${video.src}')"> |
| 43 | + <h3>${video.title}</h3> |
| 44 | + `; |
| 45 | + videoContainer.appendChild(videoElement); |
| 46 | + }); |
| 47 | +}); |
| 48 | + |
| 49 | +window.onload = loadVideos; |
0 commit comments