Go Back   CodingForums.com > :: Client side development > Graphics and Multimedia discussions

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 09-28-2011, 02:56 PM   PM User | #1
NautTboy
New Coder

 
Join Date: Jan 2009
Posts: 84
Thanks: 3
Thanked 0 Times in 0 Posts
NautTboy can only hope to improve
How to make random play?

Here is the code I have that will play in both IE and FF:

<embed name="playlist"
src="/MUSIC/playlist.m3u"
type="application/x-mplayer2"
width="300"
height="90"
loop="true"
hidden="false"
autostart="true"
shuffle="true" <--adding this didn't work
</embed>

How can I make it play random instead of the first song listed in the playlist?
NautTboy is offline   Reply With Quote
Old 09-28-2011, 03:33 PM   PM User | #2
NautTboy
New Coder

 
Join Date: Jan 2009
Posts: 84
Thanks: 3
Thanked 0 Times in 0 Posts
NautTboy can only hope to improve
found this. He said needed to make php file. I'd tried but didn't work.

<?php
$playlist = "/home/sites/myname/www.example.com/examples/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="/examples/randomsongs.php/playlist.m3u"
width="0"
height="0"
autostart="true"
type="audio/mpeg"
loop="true"/>
</body>
</html>


Not sure if i can post the link on here, i'll need to go back and read the "read me before postin"
NautTboy is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 11:36 PM.


Advertisement
Log in to turn off these ads.