pagenot responsive when clicks fix it
Browse filesadd all movies strems on clicks
remove tag stream quality from main page
instert it html5 video player on the page for movies
- components/movie-row.js +5 -3
- script.js +63 -24
components/movie-row.js
CHANGED
|
@@ -48,12 +48,13 @@ class MovieRow extends HTMLElement {
|
|
| 48 |
min-width: 200px;
|
| 49 |
transition: transform 0.3s;
|
| 50 |
position: relative;
|
|
|
|
| 51 |
}
|
| 52 |
.movie-card:hover {
|
| 53 |
transform: scale(1.05);
|
| 54 |
z-index: 10;
|
| 55 |
}
|
| 56 |
-
|
| 57 |
width: 100%;
|
| 58 |
border-radius: 4px;
|
| 59 |
cursor: pointer;
|
|
@@ -102,11 +103,12 @@ class MovieRow extends HTMLElement {
|
|
| 102 |
card.innerHTML = `
|
| 103 |
<img
|
| 104 |
class="movie-poster"
|
| 105 |
-
src="${movie.poster_path ? `https://image.tmdb.org/t/p/w200${movie.poster_path}` : 'http://static.photos/movie/200x200'}"
|
| 106 |
alt="${movie.title}"
|
| 107 |
loading="lazy"
|
|
|
|
| 108 |
>
|
| 109 |
-
|
| 110 |
container.appendChild(card);
|
| 111 |
});
|
| 112 |
}
|
|
|
|
| 48 |
min-width: 200px;
|
| 49 |
transition: transform 0.3s;
|
| 50 |
position: relative;
|
| 51 |
+
cursor: pointer;
|
| 52 |
}
|
| 53 |
.movie-card:hover {
|
| 54 |
transform: scale(1.05);
|
| 55 |
z-index: 10;
|
| 56 |
}
|
| 57 |
+
.movie-poster {
|
| 58 |
width: 100%;
|
| 59 |
border-radius: 4px;
|
| 60 |
cursor: pointer;
|
|
|
|
| 103 |
card.innerHTML = `
|
| 104 |
<img
|
| 105 |
class="movie-poster"
|
| 106 |
+
src="${movie.poster_path ? `https://image.tmdb.org/t/p/w200${movie.poster_path}` : 'http://static.photos/movie/200x200'}"
|
| 107 |
alt="${movie.title}"
|
| 108 |
loading="lazy"
|
| 109 |
+
data-movie-id="${movie.id}"
|
| 110 |
>
|
| 111 |
+
`;
|
| 112 |
container.appendChild(card);
|
| 113 |
});
|
| 114 |
}
|
script.js
CHANGED
|
@@ -1,40 +1,79 @@
|
|
|
|
|
| 1 |
document.addEventListener('DOMContentLoaded', () => {
|
| 2 |
-
// Initialize stream quality selector
|
| 3 |
-
initStreamQuality();
|
| 4 |
-
|
| 5 |
// Add upcoming movies highlight animation
|
| 6 |
highlightUpcomingMovies();
|
| 7 |
|
| 8 |
// Handle search functionality
|
| 9 |
setupSearch();
|
|
|
|
|
|
|
|
|
|
| 10 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
|
| 12 |
-
|
| 13 |
-
const
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
</div>
|
| 23 |
`;
|
| 24 |
-
document.body.appendChild(
|
| 25 |
|
| 26 |
-
//
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
btn.addEventListener('click', () => {
|
| 30 |
-
qualityBtns.forEach(b => b.classList.remove('active'));
|
| 31 |
-
btn.classList.add('active');
|
| 32 |
-
// Here you would typically update the stream quality
|
| 33 |
-
console.log(`Switched to ${btn.dataset.quality} quality`);
|
| 34 |
-
});
|
| 35 |
});
|
| 36 |
}
|
| 37 |
-
|
| 38 |
function highlightUpcomingMovies() {
|
| 39 |
// Find all upcoming movie cards and add pulse animation
|
| 40 |
setTimeout(() => {
|
|
|
|
| 1 |
+
|
| 2 |
document.addEventListener('DOMContentLoaded', () => {
|
|
|
|
|
|
|
|
|
|
| 3 |
// Add upcoming movies highlight animation
|
| 4 |
highlightUpcomingMovies();
|
| 5 |
|
| 6 |
// Handle search functionality
|
| 7 |
setupSearch();
|
| 8 |
+
|
| 9 |
+
// Handle movie card clicks
|
| 10 |
+
setupMoviePlayback();
|
| 11 |
});
|
| 12 |
+
function setupMoviePlayback() {
|
| 13 |
+
document.addEventListener('click', async (e) => {
|
| 14 |
+
const movieCard = e.target.closest('.movie-poster');
|
| 15 |
+
if (movieCard) {
|
| 16 |
+
const movieId = movieCard.dataset.movieId;
|
| 17 |
+
if (movieId) {
|
| 18 |
+
try {
|
| 19 |
+
// Fetch movie details
|
| 20 |
+
const response = await fetch(`https://api.themoviedb.org/3/movie/${movieId}?api_key=8f2b224acadeeebc64ef32b4c04919de&append_to_response=videos`);
|
| 21 |
+
const movieData = await response.json();
|
| 22 |
+
|
| 23 |
+
// Create video player
|
| 24 |
+
createVideoPlayer(movieData);
|
| 25 |
+
} catch (error) {
|
| 26 |
+
console.error('Error fetching movie details:', error);
|
| 27 |
+
}
|
| 28 |
+
}
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
// Close player when clicking outside
|
| 32 |
+
const player = document.querySelector('.video-player');
|
| 33 |
+
if (player && !e.target.closest('.video-player') && !e.target.closest('.movie-poster')) {
|
| 34 |
+
player.remove();
|
| 35 |
+
}
|
| 36 |
+
});
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
+
function createVideoPlayer(movieData) {
|
| 40 |
+
// Remove existing player if any
|
| 41 |
+
const existingPlayer = document.querySelector('.video-player');
|
| 42 |
+
if (existingPlayer) existingPlayer.remove();
|
| 43 |
|
| 44 |
+
// Find trailer video
|
| 45 |
+
const trailer = movieData.videos?.results?.find(v => v.type === 'Trailer');
|
| 46 |
+
const videoUrl = trailer
|
| 47 |
+
? `https://www.youtube.com/embed/${trailer.key}?autoplay=1`
|
| 48 |
+
: '';
|
| 49 |
+
|
| 50 |
+
const player = document.createElement('div');
|
| 51 |
+
player.className = 'video-player';
|
| 52 |
+
player.innerHTML = `
|
| 53 |
+
<div class="player-overlay"></div>
|
| 54 |
+
<div class="player-content">
|
| 55 |
+
<button class="close-player">×</button>
|
| 56 |
+
<h3>${movieData.title}</h3>
|
| 57 |
+
<p>${movieData.overview}</p>
|
| 58 |
+
${videoUrl ? `
|
| 59 |
+
<iframe
|
| 60 |
+
width="100%"
|
| 61 |
+
height="500"
|
| 62 |
+
src="${videoUrl}"
|
| 63 |
+
frameborder="0"
|
| 64 |
+
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
|
| 65 |
+
allowfullscreen>
|
| 66 |
+
</iframe>
|
| 67 |
+
` : '<p>No trailer available for this movie</p>'}
|
| 68 |
</div>
|
| 69 |
`;
|
| 70 |
+
document.body.appendChild(player);
|
| 71 |
|
| 72 |
+
// Close button event
|
| 73 |
+
player.querySelector('.close-player').addEventListener('click', () => {
|
| 74 |
+
player.remove();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 75 |
});
|
| 76 |
}
|
|
|
|
| 77 |
function highlightUpcomingMovies() {
|
| 78 |
// Find all upcoming movie cards and add pulse animation
|
| 79 |
setTimeout(() => {
|