handle live from an account
This commit is contained in:
+118
@@ -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;
|
||||
|
||||
@@ -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
|
||||
// =========================================
|
||||
|
||||
+37
-1
@@ -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
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -29,12 +29,50 @@
|
||||
<div class="hero-mastodon-wrapper">
|
||||
<!-- Hero Banner -->
|
||||
<div class="hero">
|
||||
<div class="hero-content">
|
||||
<div class="hero-logo">KAUBUNTU<span class="re">.RE</span></div>
|
||||
<div class="play-button">
|
||||
<i class="fas fa-play"></i>
|
||||
<?php
|
||||
// Vérifier s'il y a un direct en cours
|
||||
$liveStream = getLiveStream();
|
||||
|
||||
if ($liveStream) {
|
||||
// Afficher le direct en cours
|
||||
?>
|
||||
<div class="live-badge">
|
||||
<i class="fas fa-circle"></i> DIRECT
|
||||
</div>
|
||||
</div>
|
||||
<div class="hero-video-container">
|
||||
<iframe
|
||||
src="<?php echo PEERTUBE_URL; ?>/videos/embed/<?php echo $liveStream['id']; ?>?autoplay=1&muted=1"
|
||||
frameborder="0"
|
||||
allowfullscreen="allowfullscreen"
|
||||
allow="autoplay; fullscreen"
|
||||
title="<?php echo htmlspecialchars($liveStream['title']); ?>">
|
||||
</iframe>
|
||||
</div>
|
||||
<div class="hero-video-info">
|
||||
<h2><?php echo htmlspecialchars($liveStream['title']); ?></h2>
|
||||
<div class="hero-channel-info">
|
||||
<?php if (strpos($liveStream['channelAvatar'], 'default-avatar.png') !== false || empty($liveStream['channelAvatar'])): ?>
|
||||
<div class="channel-avatar-placeholder">
|
||||
<i class="fas fa-user-circle"></i>
|
||||
</div>
|
||||
<?php else: ?>
|
||||
<img src="<?php echo $liveStream['channelAvatar']; ?>" alt="<?php echo $liveStream['channel']; ?>" class="channel-avatar">
|
||||
<?php endif; ?>
|
||||
<span class="channel-name"><?php echo $liveStream['channel']; ?></span>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
} else {
|
||||
// Aucun direct en cours
|
||||
?>
|
||||
<div class="hero-no-live">
|
||||
<i class="fas fa-tv"></i>
|
||||
<h2>Aucun direct en cours</h2>
|
||||
<p>Revenez plus tard pour découvrir nos prochaines diffusions en direct.</p>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
|
||||
<div id="mt-container" class="mt-container">
|
||||
|
||||
Reference in New Issue
Block a user