Advanced Web Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsWeb DesignAdvanced Web Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old April 3rd, 2006, 11:48 PM
cantes903 cantes903 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2006
Posts: 3 cantes903 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 12 m 52 sec
Reputation Power: 0
How can I create a Randomized Playlist from an existing m3u

I have a m3u playlist of 5 mp3's which plays fine on my web page. But of course it plays in the order they are on the list. I want to "somhow" make it radom so that a person may get a different song each time they visit the site. I have looked all over for quite a while now and can't find what I need or a tutorial on how to do it. ANY help would be greatly appreciated!

thanks in advanced-
Christy

Reply With Quote
  #2  
Old April 4th, 2006, 12:48 PM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,890 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 14 m 9 sec
Reputation Power: 8
What does the m3u look like?
Are you generating it, or simply posting a saved playlist?

Does your webpage use a server-side language (such as PHP, ASP, Ruby, etc)?
__________________
Daryl's Homepage | My Blogroll | My Profile | Firefox supporter!
DevArticles Forum Moderator

"The net is a waste of time, and that's exactly what's right about it." -- William Gibson

Reply With Quote
  #3  
Old April 4th, 2006, 01:16 PM
cantes903 cantes903 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2006
Posts: 3 cantes903 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 12 m 52 sec
Reputation Power: 0
My playlist is just a listing of my songs in a notepad saved and uploaded as playlist.m3u. My server can use PHP too.

OK. Here is the closest thing I've come to so far, and it's using PHP (which I'm vaguely familiar with from school, but not even near proficient with.) What I've done is created a playlist.m3u with 5 mp3's on it. http://amigosleague.com/music/playlist.m3u

Playlist code as follows:

http://amigosleague.com/music/1.mp3
http://amigosleague.com/music/2.mp3
http://amigosleague.com/music/3.mp3
http://amigosleague.com/music/4.mp3
http://amigosleague.com/music/5.mp3


Then I created randomsongs.php and uploaded it to my server:
http://amigosleague.com/music/randomsongs.php

PHP coded as follows:

<?php
$playlist = "/www/a/m/amigosleague.com/htdocs/music/playlist.m3u";
if ($_SERVER['PATH_INFO'] == "/playlist.m3u") {
# This a request for the actual playlist.
playlist();
} else {
# Fall through to end of script and display
# the player HTML.
}
function playlist() {
header("Content-type: audio/mpeg");

# Needed for PHP versions OLDER than 4.2.0 only.
# If your host still has PHP older than 4.2.0, shame on them.
# Find a better web host.
srand(make_seed());

# Fetch our list of songs from a file.
$songs = file($playlist);
shuffle($songs);
# Now output the URLs in random order.
foreach ($songs as $song) {
# Remove newline and any other leading and trailing
# whitespace from URL of song.
$song = trim($song);
echo "$song\n";
}
# Now exit before any HTML is produced.
exit(0);
}
# Needed only for very old versions of PHP,
# see srand call earlier.
function make_seed()
{
list($usec, $sec) = explode(' ', microtime());
return (float) $sec + ((float) $usec * 100000);
}
?>
<html>
<head>
<title>MP3s Playing in Random Order</title>
</head>
<body>
<h1 align="center">MP3s Playing in Random Order</h1>
<embed src="/music/randomsongs.php/playlist.m3u"
width="200"
height="100"
autostart="true"
type="audio/mpeg"
loop="true"/>
</body>
</html>


But when you try and access the randomsongs.php link it doesn't play. Since I don't know enough about php i used a step by step from this website: http://www.boutell.com/newfaq/creating/randomsongs.html.

Reply With Quote
  #4  
Old April 5th, 2006, 08:51 AM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,890 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 14 m 9 sec
Reputation Power: 8
I found something interesting.

Accessing http://amigosleague.com/music/randomsongs.php/playlist.m3u directly gave me a blank file.
I was able to download the m3u directly using: http://amigosleague.com/music/playlist.m3u
It then streamed in my media player... I assume you want it embedded in the page.

I would look into why your script is giving out a blank file though. That's likely the cause. I also tried manually sending the HTTP requests for the m3u (while using your PHP script), and your server actually returned a 404... not sure if that's related

Reply With Quote
  #5  
Old April 5th, 2006, 08:56 AM
cantes903 cantes903 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2006
Posts: 3 cantes903 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 12 m 52 sec
Reputation Power: 0
Ok, sounds like a good idea. The problems lies in I don't know why the script isn't working. lol I posted it in the post above your last if you have any ideas. Thanks a lot for your help!

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsWeb DesignAdvanced Web Development > How can I create a Randomized Playlist from an existing m3u


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump



 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

Request Your Free Technology Downloads!
 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

Request Your Free Technology Downloads!
 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

Request Your Free Technology Downloads!
 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

Request Your Free Technology Downloads!
 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

Request Your Free Technology Downloads!
 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
Stay green...Green IT