![]() 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/5ac7d76f/ |
<?php
// This script fixes the play buttons in feed.php to work with the global player
// Read the current feed.php file
$feed_content = file_get_contents('feed.php');
// Find and replace the play button onclick handlers
$search_pattern = '/onclick="feedPlayTrack\(\'([^\']+)\', \'([^\']+)\', \'([^\']+)\', ([^)]+)\)"/';
$replace_pattern = 'onclick="playTrackWithGlobalPlayer(\'$1\', \'$2\', \'$3\', $4)"';
$new_content = preg_replace($search_pattern, $replace_pattern, $feed_content);
// Also add a simple play function that works with global player
$play_function = '
// Simple play function for track cards
function playTrackWithGlobalPlayer(audioUrl, title, artist, artistId) {
console.log("🎵 Play button clicked:", { audioUrl, title, artist, artistId });
// Validate audio URL
if (!audioUrl || audioUrl === "null" || audioUrl === "undefined" || audioUrl === "") {
console.error("🎵 INVALID AUDIO URL:", audioUrl);
return;
}
// Try to use global player
if (typeof window.globalPlayer !== "undefined" && typeof window.globalPlayer.playTrack === "function") {
try {
console.log("🎵 Using global player to play track");
// Ensure global player is visible
if (typeof window.globalPlayer.showPlayer === "function") {
window.globalPlayer.showPlayer();
}
// Set wasPlaying to true so it auto-plays
window.globalPlayer.wasPlaying = true;
// Play the track
window.globalPlayer.playTrack(audioUrl, title, artist, artistId);
console.log("🎵 Track started playing");
return;
} catch (error) {
console.error("🎵 Global player error:", error);
}
}
// Fallback: try to use the global function
if (typeof window.playTrackWithGlobalPlayer === "function") {
try {
console.log("🎵 Using global playTrackWithGlobalPlayer function");
window.playTrackWithGlobalPlayer(audioUrl, title, artist, artistId);
return;
} catch (error) {
console.error("🎵 Global function error:", error);
}
}
// Final fallback: try to initialize global player and play
console.log("🎵 Attempting to initialize global player and play");
if (typeof initializeGlobalPlayer === "function") {
initializeGlobalPlayer();
// Wait a bit and try again
setTimeout(() => {
if (typeof window.globalPlayer !== "undefined" && typeof window.globalPlayer.playTrack === "function") {
window.globalPlayer.wasPlaying = true;
window.globalPlayer.playTrack(audioUrl, title, artist, artistId);
}
}, 1000);
}
}
';
// Insert the play function before the closing script tag
$script_end = '</script>';
$new_content = str_replace($script_end, $play_function . $script_end, $new_content);
// Write the updated content back to feed.php
file_put_contents('feed.php', $new_content);
echo "Feed.php play buttons have been fixed!\n";
echo "The play buttons now use playTrackWithGlobalPlayer() function.\n";
echo "This function will:\n";
echo "1. Try to use the global player directly\n";
echo "2. Fall back to the global playTrackWithGlobalPlayer function\n";
echo "3. Initialize the global player if needed\n";
echo "4. Handle errors gracefully without showing popups\n";
?>