Web Design Forum  
 
Go Back   Web Design Forum > Web Software > Scripts

Reply
 
LinkBack Thread Tools Display Modes
Old 02-08-2009, 02:04 AM   #1
New Member
 
Join Date: Feb 2009
Posts: 5
Red face Embedded Player, Songs from Folder Script

Hello All,

This is something I'm really eager to get working, and I'm part of the way there

What I want:

To have an MP3 player on a web page. When people upload their MP3's to a specific folder online, the player automatically adds the songs to it's playlist. When people delete the songs from that folder, they are removed from the playlist.

I've worked with a friend and we are part way there.

www.wibblywobblywebsite.com/testzone/test.html

The PHP code inside the folder with the MPs looks like this:

Code:
<?
function isMp3($filename){
    $ext = substr($filename, -4);
    if($ext == '.mp3'){
        return true;
    }else{
        return false;
    }
}

$d = dir(getcwd());
while (false !== ($filename = $d->read())) {
    if(isMp3($filename)){
        $playlist .= $filename . '|';
    }
}
$d->close();
echo "mp3=" . substr($playlist, 0, strlen($playlist) - 1);
?>
Here is the page with the player on it:

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>
</head>

<body>

<div>
  <object type="application/x-shockwave-flash" data="http://www.wibblywobblywebsite.com/testzone/player/player_mp3_multi.swf" height=500 width=500>
  <param name="movie" value="http://www.wibblywobbywebsite.com/testzone/player/player_mp3_multi.swf" />
  <param name="wmode" value="transparent" />
  <param name="FlashVars" value="config=http://www.wibblywobblywebsite.com/testzone/playlist/playlist.php" />
  </object>
</div>


</body>
</html>
The Playlist is formed, but the songs won't play.

I really don't know coding very well. Can anyone see how to get this working?

The idea is, that users will be able to upload songs from a content management system into this folder and the MP3 player will play them.

On another design forum, someone said that I was missing part of the URL's, could this be it?

Many thanks in advance for your help!

- Wibbly
wibblywobbly is offline   Reply With Quote


Old 02-08-2009, 02:26 AM   #2
New Member
 
Join Date: Feb 2009
Posts: 5
Smile

FIRST!

I'm the first to post on my own post.

I've found the problem, but I don't know how to solve it.

The MP3's and the PHP script are in a folder called "playlist" located at testzone/playlist.

But the way the code is set up, it's looking for the MP3s in testzone
- so it's missing out the /playlist part of the address.

Can anyone tell me how to make the code look in testzone/playlist?

What if my MP3 folder was on a different server all together, how would I direct the code to look there?

I wish I could get good at scripting, my eyes turn crossed at the moment,

Thanks,
Wibbly.
wibblywobbly is offline   Reply With Quote
Old 02-11-2009, 10:08 PM   #3
New Member
 
Join Date: Feb 2009
Posts: 5
Cool

SECOND!

It would be great if anyone had any advice about this!

Here's where I've got to now: The player is generating the playlist, but not playing the .mp3s. This is something to do with the way the PHP form specifies the locations of the .mp3s.

I've tried changing the PHP from this:
Code:
$d = dir(getcwd());
To this:
Code:
$d = dir("/testzone/playlist");
This way I'm saying exactly where the location is.

Sadly, this didn't work, and the player threw me an error message. I hate PHP, anyone have any suggestions?

Thanks.
-- Wibbly.
wibblywobbly is offline   Reply With Quote
Old 02-12-2009, 03:22 AM   #4
New Member
 
Join Date: Feb 2009
Location: Canada eh!
Posts: 9
Default

Heh, I think that was my suggestion from another forum. What is the error message?

Are you sure of the path?

To get the full absolute path, put this in a php file in the same folder as your mp3 files and load it in a browser:

<?
echo realpath('./');
?>

See if that matches the path you are using.

-Erik
Erik is offline   Reply With Quote
Old 02-12-2009, 10:51 AM   #5
New Member
 
Join Date: Feb 2009
Posts: 5
Default

Hello Erik!

It was your suggestion, and thank you so much for it. I mentioned this on the other forum too.

I'm really desperate to finish this project, and this is the final part.

The error message I was getting was, "Liste Vide"

But, I've followed your suggestion and created the PHP location file and put it in the playlist folder (http://www.wibblywobblywebsite.com/t...t/location.php). What this has told me is the correct, full location is:

Code:
/home/wibblywo/public_html/testzone/playlist
So I've changed my playlist.php to:

Code:
$d = dir("/home/wibblywo/public_html/testzone/playlist");
Now it's generating the playlist again. But still not playing the mp3s

If I move the mp3s from the playlist folder into the testzone folder, so that they're alongside the html, they play...

Thanks for your help so far, I'm going to post progress on the other forum too.

-- Wibbly.
wibblywobbly is offline   Reply With Quote


Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 04:00 AM.


Camera Forum - Computer Forum - Web Design Forum

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
Content Relevant URLs by vBSEO 3.6.0 ©2011, Crawlability, Inc.