![]() Server : Apache/2 System : Linux server-15-235-50-60 5.15.0-164-generic #174-Ubuntu SMP Fri Nov 14 20:25:16 UTC 2025 x86_64 User : gositeme ( 1004) PHP Version : 8.2.29 Disable Function : exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname Directory : /home/gositeme/.cursor-server/data/User/History/-55310197/ |
<?php
session_start();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Test Library Fix</title>
<style>
body { font-family: Arial, sans-serif; padding: 20px; background: #f5f5f5; }
.test-container { max-width: 800px; margin: 0 auto; background: white; padding: 20px; border-radius: 10px; }
.test-button {
background: #667eea;
color: white;
padding: 15px 30px;
border: none;
border-radius: 8px;
cursor: pointer;
margin: 10px;
font-size: 16px;
}
.status { margin: 15px 0; padding: 15px; border-radius: 8px; }
.success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.error { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }
.info { background: #d1ecf1; color: #0c5460; border: 1px solid #bee5eb; }
</style>
</head>
<body>
<div class="test-container">
<h1>๐ต Test Library Play Button Fix</h1>
<div class="status info">
<h3>๐ง What This Tests:</h3>
<p>This page tests if the library.php play button now correctly sends tracks to the global player in the footer.</p>
<p>The issue was that the global player wasn't fully initialized when the play button was clicked.</p>
</div>
<div class="status info">
<h3>โ
Fix Applied:</h3>
<p>1. Moved <code>window.globalPlayerReady = true</code> to after the <code>enhancedGlobalPlayer</code> object is created</p>
<p>2. This ensures the global player is fully ready before any play buttons try to use it</p>
</div>
<div class="status info">
<h3>๐งช Test Steps:</h3>
<p>1. Click the test button below</p>
<p>2. Check if the track appears in the global player at the bottom</p>
<p>3. Verify the play button works on the actual library.php page</p>
</div>
<div style="text-align: center; margin: 30px 0;">
<button class="test-button" onclick="testPlayButton()">
๐ต Test Play Button (Simulates library.php)
</button>
</div>
<div id="test-results" class="status" style="display: none;"></div>
<div style="text-align: center; margin: 30px 0;">
<a href="/library.php" class="test-button" style="text-decoration: none;">๐ Go to Library Page</a>
<a href="/debug_library_player.php" class="test-button" style="text-decoration: none;">๐ง Debug Page</a>
</div>
</div>
<script>
// This simulates exactly what happens in library.php
async function testPlayButton() {
console.log('๐ต Testing library play button (simulating library.php)...');
const resultsDiv = document.getElementById('test-results');
resultsDiv.style.display = 'block';
resultsDiv.className = 'status info';
resultsDiv.innerHTML = '<h3>๐ Testing...</h3><p>Clicking play button and checking global player...</p>';
try {
// Simulate the exact playTrackFromButton function from library.php
await playTrackFromButton('https://www.soundjay.com/misc/sounds/bell-ringing-05.wav', 'Test Track', 'Test Artist');
resultsDiv.className = 'status success';
resultsDiv.innerHTML = `
<h3>โ
Test Successful!</h3>
<p>๐ต Play button clicked successfully</p>
<p>๐ต Track should now be playing in the global player below</p>
<p>๐ต Check the footer player to confirm it's working</p>
`;
} catch (error) {
resultsDiv.className = 'status error';
resultsDiv.innerHTML = `
<h3>โ Test Failed</h3>
<p>Error: ${error.message}</p>
<p>Check console for more details</p>
`;
}
}
// Exact copy of the playTrackFromButton function from library.php
async function playTrackFromButton(audioUrl, title, artist) {
console.log('๐ต Library: playTrackFromButton called with:', { audioUrl, title, artist });
if (!audioUrl) {
console.warn('No audio URL provided');
throw new Error('No audio URL provided');
}
// Wait for enhanced global player to be ready
await waitForEnhancedPlayer();
// Use the enhanced global player (same as community.php)
if (typeof window.enhancedGlobalPlayer !== 'undefined' && typeof window.enhancedGlobalPlayer.playTrack === 'function') {
window.enhancedGlobalPlayer.playTrack(audioUrl, title, artist);
// Update currently playing state
const trackId = getTrackIdFromAudioUrl(audioUrl);
console.log('๐ต Library: Track ID for playing state:', trackId);
updateCurrentlyPlaying(trackId);
console.log('๐ต Library: Track sent via enhancedGlobalPlayer -', title);
} else {
console.warn('Enhanced global player not available');
throw new Error('Audio player not available. Please refresh the page and try again.');
}
}
function waitForEnhancedPlayer() {
return new Promise((resolve) => {
if (window.enhancedGlobalPlayer) {
resolve();
} else {
const checkPlayer = () => {
if (window.enhancedGlobalPlayer) {
resolve();
} else {
setTimeout(checkPlayer, 100);
}
};
checkPlayer();
}
});
}
function getTrackIdFromAudioUrl(audioUrl) {
const urlParts = audioUrl.split('/');
return urlParts[urlParts.length - 1] || 'unknown';
}
function updateCurrentlyPlaying(trackId) {
console.log('๐ต Updating currently playing state for track:', trackId);
}
// Check global player status on page load
document.addEventListener('DOMContentLoaded', function() {
console.log('๐ต Test page loaded');
setTimeout(() => {
console.log('๐ต Global player status:', {
enhancedGlobalPlayer: typeof window.enhancedGlobalPlayer !== 'undefined',
playTrack: typeof window.enhancedGlobalPlayer?.playTrack === 'function',
globalPlayerReady: typeof window.globalPlayerReady !== 'undefined'
});
}, 2000);
});
</script>
<?php include 'includes/footer.php'; ?>
</body>
</html>