herghost Posted April 18, 2009 Share Posted April 18, 2009 Hi all, I have a music player which pulls files from a folder called mp3 currently and works as it is all fine and dandy. It is called by a form like so: <table align="center" border="0" cellspacing="0"cellpadding="0"><tbody><tr><td> </td></tr><div align="center"> <script language='JavaScript' src='musicplayer.js' type='text/javascript'></script></div> <tr><td><div align="center"><font face="Arial" font size="1"></font></div> </td></tr></tbody></table> which loads a .js document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'); document.write('codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="301" height="212">'); document.write('<param name="movie" value="musicplayer.swf?playlist=playlist.php" />'); document.write('<param name="quality" value="high" />'); document.write('<param name="wmode" value="transparent" />'); document.write('<embed src="musicplayer.swf?playlist=playlist.php" quality="high" wmode="transparent"'); document.write('pluginspage="http://www.macromedia.com/go/getflashplayer"'); document.write('type="application/x-shockwave-flash" width="301" height="212">'); document.write('</embed></object>'); Which in turn calls playlist.php: <?php // setting the directory to search for mp3 files $dir = "mp3/"; // reading the directory and inserting the mp3 files in the playlist array $playlist = array(); $fdir = opendir($dir); while($i = readdir($fdir)) { // if a .mp3 string is found, add the file to the array if (strpos(strtolower($i),".mp3") !== false) $playlist[] = $i; } // close the directory closedir($fdir); sort($playlist);// make an alphabetical ordered list (if you don't want an ordered list, just comment this line) shuffle($playlist);// make a randomized list (if you don't want a randomized list, just comment this line) header("Content-type: text/xml"); // echoing the playlist to flash echo "<player showDisplay=\"yes\" showPlaylist=\"yes\" autoStart=\"no\">\n"; for ($i=0; $i<sizeof($playlist); $i++) { // for the title it filters the directory and the .mp3 extension out $title = str_replace(".mp3","",$playlist[$i]); // clean filename (convert "_" into " ") $title = str_replace("_", " ", $title); echo " <song path=\"$dir{$playlist[$i]}\" title=\"$title\" />"; } echo "</player>"; ?> Which is great if I just wanted to load a list of mp3's but here is my issue. This website is based on user profiles, in each profile I only want the player to select mp3's by that person in particular. Currently when a user signs up a folder is created and named by there auto_increment userid. When they upload songs they are saved to this folder. Now for the nitty gritty. The player resides on the public viewable profile page, for example newprofile.php?userid=6 What I want the script to do is call the folder in question when you view a particular profile. Below is a short section of newprofile.php, I havent posted all of it as its currently about 1200 lines long and most of is not relevant as it works! <?php session_start(); include('include/database.php'); $userid = $_GET['userid']; ?> <table align="center" border="0" cellspacing="0"cellpadding="0"><tbody><tr><td> </td></tr><div align="center"> <script language='JavaScript' src='musicplayer.js' type='text/javascript'></script></div> <tr><td><div align="center"><font face="Arial" font size="1"></font></div> </td></tr></tbody></table> The $userid I am guessing is crucial here as this is how the folder is named, but I cannot see how to do this as the playlist.php file has none of this code, just the code placed near the top of this question. So my question is, how do I get profile.php to get the userid so I can have something like: $dir = "users/$userid/"; I hope this is all clear! Cheers Cheers Link to comment https://forums.phpfreaks.com/topic/154675-solved-music-player-folder-help/ Share on other sites More sharing options...
herghost Posted April 19, 2009 Author Share Posted April 19, 2009 never mind, I sorted it, I just used a session to store the userid in. Link to comment https://forums.phpfreaks.com/topic/154675-solved-music-player-folder-help/#findComment-813731 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.