![]() 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/66f3b4eb/ |
<?php
session_start();
// Check if user is logged in
if (!isset($_SESSION['user_id'])) {
header('Location: /auth/login.php');
exit;
}
require_once 'config/database.php';
$pdo = getDBConnection();
$user_id = $_SESSION['user_id'];
// Get feed tracks like the actual feed page
$stmt = $pdo->prepare("
SELECT
mt.id,
mt.title,
mt.prompt,
mt.audio_url,
mt.duration,
mt.created_at,
u.name as artist_name,
u.id as artist_id,
(SELECT COUNT(*) FROM track_likes WHERE track_id = mt.id) as like_count,
(SELECT COUNT(*) FROM track_comments WHERE track_id = mt.id) as comment_count,
(SELECT COUNT(*) FROM track_likes WHERE track_id = mt.id AND user_id = ?) as user_liked
FROM music_tracks mt
JOIN users u ON mt.user_id = u.id
WHERE mt.status = 'complete'
ORDER BY mt.created_at DESC
LIMIT 3
");
$stmt->execute([$user_id]);
$feed_tracks = $stmt->fetchAll();
$page_title = 'Debug Feed Play - SoundStudioPro';
$current_page = 'debug';
include 'includes/header.php';
?>
<div style="padding: 2rem; color: white; background: #0a0a0a; min-height: 100vh;">
<h1>🔍 Debug Feed Play Buttons</h1>
<div style="margin: 2rem 0; padding: 2rem; background: rgba(255,255,255,0.1); border-radius: 12px;">
<h2>Feed Tracks (Like Real Feed Page)</h2>
<?php if (!empty($feed_tracks)): ?>
<?php foreach ($feed_tracks as $track): ?>
<div style="padding: 1rem; margin: 1rem 0; background: rgba(255,255,255,0.05); border-radius: 8px;">
<h3><?= htmlspecialchars($track['title']) ?></h3>
<p><strong>Artist:</strong> <?= htmlspecialchars($track['artist_name']) ?></p>
<p><strong>Audio URL:</strong> <?= htmlspecialchars($track['audio_url']) ?></p>
<button onclick="playTrackWithGlobalPlayer('<?= htmlspecialchars($track['audio_url']) ?>', '<?= htmlspecialchars($track['title']) ?>', '<?= htmlspecialchars($track['artist_name']) ?>')" style="background: #667eea; color: white; padding: 1rem 2rem; border: none; border-radius: 8px; cursor: pointer; margin: 1rem 0;">
🎵 Play (Global Function)
</button>
<button onclick="playTrack('<?= htmlspecialchars($track['audio_url']) ?>', '<?= htmlspecialchars($track['title']) ?>', '<?= htmlspecialchars($track['artist_name']) ?>')" style="background: #48bb78; color: white; padding: 1rem 2rem; border: none; border-radius: 8px; cursor: pointer; margin: 1rem 0;">
🎵 Play (Local Function)
</button>
<button onclick="testDirectPlay('<?= htmlspecialchars($track['audio_url']) ?>')" style="background: #e53e3e; color: white; padding: 1rem 2rem; border: none; border-radius: 8px; cursor: pointer; margin: 1rem 0;">
🎵 Direct Audio Test
</button>
</div>
<?php endforeach; ?>
<?php else: ?>
<p>No tracks found</p>
<?php endif; ?>
</div>
<div style="margin: 2rem 0; padding: 2rem; background: rgba(255,255,255,0.1); border-radius: 12px;">
<h2>Function Status</h2>
<div id="functionStatus">Loading...</div>
</div>
<div style="margin: 2rem 0; padding: 2rem; background: rgba(255,255,255,0.1); border-radius: 12px;">
<h2>Console Logs</h2>
<p>Check browser console for detailed logs...</p>
</div>
</div>
<script>
// Local playTrack function (like feed page)
function playTrack(audioUrl, title, artist) {
console.log('🎵 Local playTrack called:', { audioUrl, title, artist });
// Validate audio URL
if (!audioUrl || audioUrl === 'null' || audioUrl === 'undefined' || audioUrl === '') {
console.error('🎵 INVALID AUDIO URL:', audioUrl);
return;
}
// Use the global player function
if (typeof window.playTrackWithGlobalPlayer === 'function') {
try {
console.log('🎵 Calling window.playTrackWithGlobalPlayer...');
window.playTrackWithGlobalPlayer(audioUrl, title, artist);
console.log('🎵 window.playTrackWithGlobalPlayer called successfully');
} catch (error) {
console.error('🎵 Global player error:', error);
}
} else if (typeof window.globalPlayer !== 'undefined' && window.globalPlayer.playTrack) {
try {
console.log('🎵 Calling window.globalPlayer.playTrack...');
window.globalPlayer.playTrack(audioUrl, title, artist);
console.log('🎵 window.globalPlayer.playTrack called successfully');
} catch (error) {
console.error('🎵 Direct global player error:', error);
}
} else {
console.error('🎵 Global player not available');
console.log('🎵 window.playTrackWithGlobalPlayer:', typeof window.playTrackWithGlobalPlayer);
console.log('🎵 window.globalPlayer:', typeof window.globalPlayer);
if (typeof window.globalPlayer !== 'undefined') {
console.log('🎵 window.globalPlayer.playTrack:', typeof window.globalPlayer.playTrack);
}
}
}
// Direct audio test
function testDirectPlay(audioUrl) {
console.log('🎵 Testing direct audio:', audioUrl);
try {
const audio = new Audio(audioUrl);
audio.volume = 0.5;
audio.play().then(() => {
console.log('🎵 DIRECT AUDIO PLAYING!');
alert('DIRECT AUDIO IS PLAYING!');
}).catch(error => {
console.error('🎵 Direct audio failed:', error);
alert('Direct audio failed: ' + error.message);
});
} catch (error) {
console.error('🎵 Direct audio creation failed:', error);
alert('Direct audio creation failed: ' + error.message);
}
}
function checkFunctionStatus() {
const statusDiv = document.getElementById('functionStatus');
let status = '<h3>Function Status:</h3>';
// Check global player object
if (typeof window.globalPlayer !== 'undefined') {
status += '<p>✅ window.globalPlayer object exists</p>';
if (window.globalPlayer.playTrack) {
status += '<p>✅ window.globalPlayer.playTrack method exists</p>';
} else {
status += '<p>❌ window.globalPlayer.playTrack method missing</p>';
}
if (window.globalPlayer.showPlayer) {
status += '<p>✅ window.globalPlayer.showPlayer method exists</p>';
} else {
status += '<p>❌ window.globalPlayer.showPlayer method missing</p>';
}
} else {
status += '<p>❌ window.globalPlayer object missing</p>';
}
// Check global function
if (typeof window.playTrackWithGlobalPlayer === 'function') {
status += '<p>✅ window.playTrackWithGlobalPlayer function exists</p>';
} else {
status += '<p>❌ window.playTrackWithGlobalPlayer function missing</p>';
}
// Check local function
if (typeof playTrack === 'function') {
status += '<p>✅ playTrack function exists (local)</p>';
} else {
status += '<p>❌ playTrack function missing (local)</p>';
}
// Check global player element
const playerElement = document.getElementById('globalMusicPlayer');
if (playerElement) {
status += '<p>✅ Global player DOM element exists</p>';
status += '<p>Player display: ' + playerElement.style.display + '</p>';
status += '<p>Player visibility: ' + playerElement.style.visibility + '</p>';
} else {
status += '<p>❌ Global player DOM element missing</p>';
}
statusDiv.innerHTML = status;
}
// Auto-check on page load
document.addEventListener('DOMContentLoaded', function() {
console.log('🎵 Debug feed page loaded');
setTimeout(checkFunctionStatus, 1000);
// Log all available functions
console.log('🎵 Available functions:');
console.log('🎵 window.globalPlayer:', typeof window.globalPlayer);
console.log('🎵 window.playTrackWithGlobalPlayer:', typeof window.playTrackWithGlobalPlayer);
console.log('🎵 playTrack:', typeof playTrack);
// Test if global player is initialized
if (typeof window.globalPlayer !== 'undefined') {
console.log('🎵 Global player properties:', Object.keys(window.globalPlayer));
}
});
</script>
<?php include 'includes/footer.php'; ?>