diff --git a/css/styles.css b/css/styles.css index 3ab4ff8..5f9da5b 100644 --- a/css/styles.css +++ b/css/styles.css @@ -215,6 +215,124 @@ img { border-radius: 8px; } +/* Styles pour le lecteur vidéo dans le hero */ +.hero-video-container { + position: relative; + width: 100%; + height: 100%; + overflow: hidden; +} + +.hero-video-container iframe { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + border: none; +} + +.hero-video-info { + position: absolute; + bottom: 70px; + left: 0; + width: 100%; + background: linear-gradient(transparent, rgba(0, 0, 0, 0.7)); + color: #fff; + padding: 15px; + z-index: 5; + pointer-events: none; +} + +.hero-video-info h2 { + font-size: 16px; + margin-bottom: 5px; + font-weight: 600; + text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.7); + opacity: 0.9; +} + +.hero-channel-info { + display: flex; + align-items: center; + opacity: 0.8; +} + +.hero-channel-info .channel-avatar, +.hero-channel-info .channel-avatar-placeholder { + width: 24px; + height: 24px; + border-radius: 50%; + margin-right: 8px; +} + +.hero-channel-info .channel-name { + font-size: 14px; + font-weight: 500; +} + +.live-badge { + position: absolute; + top: 10px; + left: 10px; + background-color: var(--primary-red); + color: white; + border-radius: 4px; + padding: 5px 10px; + font-size: 14px; + font-weight: bold; + z-index: 10; + display: flex; + align-items: center; + gap: 5px; +} + +.live-badge i { + font-size: 10px; + animation: pulse 1.5s infinite; +} + +@keyframes pulse { + 0% { opacity: 1; } + 50% { opacity: 0.5; } + 100% { opacity: 1; } +} + +/* Message quand aucun direct n'est disponible */ +.hero-no-live { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + background-color: rgba(0, 0, 0, 0.7); + color: white; + text-align: center; + padding: 20px; +} + +.hero-no-live i { + font-size: 50px; + margin-bottom: 20px; + opacity: 0.8; +} + +.hero-no-live h2 { + font-size: 24px; + font-weight: 600; + margin-bottom: 15px; +} + +.hero-no-live p { + font-size: 16px; + max-width: 80%; + opacity: 0.9; +} + #mt-container { width: 50%; height: 400px; diff --git a/includes/config.local.php.sample b/includes/config.local.php.sample index 9f303c4..aa30dca 100644 --- a/includes/config.local.php.sample +++ b/includes/config.local.php.sample @@ -23,6 +23,9 @@ // Clé d'API PeerTube (optionnelle) // define('API_KEY', 'votre_cle_api'); +// Compte PeerTube pour les lives +// define('LIVE_ACCOUNT_NAME', 'admin'); + // ========================================= // Filtres et tags // ========================================= diff --git a/includes/config.php b/includes/config.php index 82f6dbf..4e26d6d 100644 --- a/includes/config.php +++ b/includes/config.php @@ -88,6 +88,9 @@ if (!defined('ENABLE_USER_ACCOUNTS')) define('ENABLE_USER_ACCOUNTS', false); if (!defined('CACHE_ENABLED')) define('CACHE_ENABLED', false); if (!defined('CACHE_DURATION')) define('CACHE_DURATION', 3600); // En secondes (1 heure) +// Compte pour les lives +if (!defined('LIVE_ACCOUNT_NAME')) define('LIVE_ACCOUNT_NAME', 'admin'); + // Tags pour filtrer les vidéos selon les catégories if (!defined('TAG_SHORT')) define('TAG_SHORT', 'short'); @@ -275,6 +278,38 @@ function getIndependenceVideos($count = INDEPENDENCE_VIDEOS_COUNT) { return getVideosByTag(TAG_INDEPENDENCE, $count); } +/** + * Vérifie s'il y a un direct en cours du compte LIVE_ACCOUNT_NAME sur l'instance PeerTube + * + * @return array|null Informations sur le direct en cours ou null si aucun direct + */ +function getLiveStream() { + // Récupérer les lives du compte spécifié + $accountName = LIVE_ACCOUNT_NAME; + $data = callPeerTubeApi('accounts/' . $accountName . '/videos', [ + 'count' => 1, + 'isLocal' => true, + 'isLive' => true, // Filtrer uniquement les lives + 'sort' => '-publishedAt' // Les plus récents en premier + ]); + + // Vérifier si on a des résultats + if (empty($data['data']) || count($data['data']) === 0) { + return null; + } + + // Formater les données du live + $liveData = formatVideosData($data['data']); + + // Filtrer pour ne garder que les lives en cours + $activeLives = array_filter($liveData, function($video) { + return isset($video['isLive']) && $video['isLive'] === true; + }); + + // Retourner le premier live trouvé + return !empty($activeLives) ? reset($activeLives) : null; +} + /** * Formate les données brutes des vidéos venant de l'API * @@ -307,7 +342,8 @@ function formatVideosData($videosData) { 'date' => $video['publishedAt'], 'aspectRatio' => $video['aspectRatio'], 'description' => $video['description'] ?? '', - 'tags' => $video['tags'] ?? [] + 'tags' => $video['tags'] ?? [], + 'isLive' => isset($video['isLive']) ? $video['isLive'] : false ]; } diff --git a/index.php b/index.php index 5f89a46..ddd8164 100644 --- a/index.php +++ b/index.php @@ -29,12 +29,50 @@
Revenez plus tard pour découvrir nos prochaines diffusions en direct.
+