Auto commit: 2026-02-25T20:09:50.809Z
This commit is contained in:
parent
ca1b853970
commit
f81d4e8569
@ -16,6 +16,14 @@ try {
|
|||||||
$remaining = $endAt - time();
|
$remaining = $endAt - time();
|
||||||
|
|
||||||
if ($remaining > 0) {
|
if ($remaining > 0) {
|
||||||
|
// Find next track for local requests
|
||||||
|
$stmtNext = $db->query("SELECT artist, song FROM song_requests WHERE status = 'pending' ORDER BY is_priority DESC, created_at ASC LIMIT 1");
|
||||||
|
$nextTrack = $stmtNext->fetch();
|
||||||
|
$nextInfo = null;
|
||||||
|
if ($nextTrack) {
|
||||||
|
$nextInfo = ['artist' => $nextTrack['artist'], 'title' => $nextTrack['song']];
|
||||||
|
}
|
||||||
|
|
||||||
echo json_encode([
|
echo json_encode([
|
||||||
'success' => true,
|
'success' => true,
|
||||||
'source' => 'local_request',
|
'source' => 'local_request',
|
||||||
@ -27,6 +35,7 @@ try {
|
|||||||
'started_at' => date('c', $startedAt),
|
'started_at' => date('c', $startedAt),
|
||||||
'end_at' => date('c', $endAt),
|
'end_at' => date('c', $endAt),
|
||||||
'remaining' => $remaining,
|
'remaining' => $remaining,
|
||||||
|
'next_track' => $nextInfo,
|
||||||
'cover' => './assets/pasted-20260215-163754-def41f49.png'
|
'cover' => './assets/pasted-20260215-163754-def41f49.png'
|
||||||
]);
|
]);
|
||||||
exit;
|
exit;
|
||||||
@ -53,6 +62,14 @@ try {
|
|||||||
$startedAt = date('c', strtotime($endAt) - $duration);
|
$startedAt = date('c', strtotime($endAt) - $duration);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// For RadioKing source, check if there's a pending local request (it will be next)
|
||||||
|
$nextInfo = $data['next_track'] ?? null;
|
||||||
|
$stmtNext = $db->query("SELECT artist, song FROM song_requests WHERE status = 'pending' ORDER BY is_priority DESC, created_at ASC LIMIT 1");
|
||||||
|
$localNext = $stmtNext->fetch();
|
||||||
|
if ($localNext) {
|
||||||
|
$nextInfo = ['artist' => $localNext['artist'], 'title' => $localNext['song']];
|
||||||
|
}
|
||||||
|
|
||||||
echo json_encode([
|
echo json_encode([
|
||||||
'success' => true,
|
'success' => true,
|
||||||
'source' => 'radioking',
|
'source' => 'radioking',
|
||||||
@ -62,7 +79,7 @@ try {
|
|||||||
'duration' => $duration,
|
'duration' => $duration,
|
||||||
'started_at' => $startedAt,
|
'started_at' => $startedAt,
|
||||||
'end_at' => $endAt,
|
'end_at' => $endAt,
|
||||||
'next_track' => $data['next_track'] ?? null
|
'next_track' => $nextInfo
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
29
index.php
29
index.php
@ -4444,6 +4444,8 @@ $twitter_link = "https://twitter.com/";
|
|||||||
|
|
||||||
// Fetch Now Playing Metadata
|
// Fetch Now Playing Metadata
|
||||||
let progressInterval = null;
|
let progressInterval = null;
|
||||||
|
let nextSongNoticeSent = false;
|
||||||
|
let currentTrackId = '';
|
||||||
|
|
||||||
async function updateMetadata() {
|
async function updateMetadata() {
|
||||||
try {
|
try {
|
||||||
@ -4460,6 +4462,8 @@ $twitter_link = "https://twitter.com/";
|
|||||||
const requester = data.requester || '';
|
const requester = data.requester || '';
|
||||||
|
|
||||||
if (trackTitle.textContent !== title) {
|
if (trackTitle.textContent !== title) {
|
||||||
|
nextSongNoticeSent = false;
|
||||||
|
currentTrackId = fullDisplay;
|
||||||
// If it's a local request, show special label
|
// If it's a local request, show special label
|
||||||
const label = document.querySelector('.track-label');
|
const label = document.querySelector('.track-label');
|
||||||
if (source === 'local_request') {
|
if (source === 'local_request') {
|
||||||
@ -4620,6 +4624,31 @@ $twitter_link = "https://twitter.com/";
|
|||||||
function updateProgressBar() {
|
function updateProgressBar() {
|
||||||
const now = new Date().getTime();
|
const now = new Date().getTime();
|
||||||
const elapsed = now - start;
|
const elapsed = now - start;
|
||||||
|
|
||||||
|
// Check if we should send next song notice (approx 30s before end)
|
||||||
|
const remainingSec = Math.floor((end - now) / 1000);
|
||||||
|
if (remainingSec <= 30 && remainingSec > 25 && !nextSongNoticeSent && data.next_track) {
|
||||||
|
nextSongNoticeSent = true;
|
||||||
|
let nextLabel = "";
|
||||||
|
if (typeof data.next_track === 'object') {
|
||||||
|
const nextArtist = data.next_track.artist || 'Artista';
|
||||||
|
const nextTitle = data.next_track.title || 'Título';
|
||||||
|
nextLabel = `${nextArtist} - ${nextTitle}`;
|
||||||
|
} else {
|
||||||
|
nextLabel = data.next_track;
|
||||||
|
}
|
||||||
|
const nextMsg = `⏭️ **Próxima canción:** ${nextLabel} 🎶`;
|
||||||
|
fetch('api/chat.php', {
|
||||||
|
method: 'POST',
|
||||||
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
body: JSON.stringify({
|
||||||
|
username: 'Sistema',
|
||||||
|
message: nextMsg,
|
||||||
|
type: 'dj_power'
|
||||||
|
})
|
||||||
|
}).catch(err => console.error('Error sending next track notice:', err));
|
||||||
|
}
|
||||||
|
|
||||||
let percent = (elapsed / duration) * 100;
|
let percent = (elapsed / duration) * 100;
|
||||||
if (percent > 100) percent = 100;
|
if (percent > 100) percent = 100;
|
||||||
if (percent < 0) percent = 0;
|
if (percent < 0) percent = 0;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user