Search…

X3 Photo Gallery Support Forums

Search…
 
User avatar
joey
Experienced
Topic Author
Posts: 31
Joined: 28 Sep 2006, 16:18

A work-around for random mp3 playlist

07 Dec 2006, 15:10

You need to follow these steps to get it working:
1. drop rename.php in your gallery folder
2. add this line in your index.php:
Code
require_once('rename.php');
Contents of rename.php:
Code
<?php

// Rename files with random names

$musicdir = @opendir("mp3"); 
$cc = 0;
while($filename = readdir($musicdir)) {
	if (ereg("\.mp3|\.MP3", $filename)) 
	{ 
		$namearray[$cc] = "mp3/". $filename; $cc++; 
	}
}

for ($i=0; $i<count($namearray); $i++) {
	$extension = strstr($namearray[$i], ".");
	$rndnm = "mp3/". rand(10,1000) . $extension;
	@rename($namearray[$i], $rndnm);
}

?>
Karl or anyone else: If you think this will introduce bugs or have better solutions, please advise.

Thanks!
Last edited by joey on 11 Dec 2006, 09:47, edited 1 time in total.
 
User avatar
joey
Experienced
Topic Author
Posts: 31
Joined: 28 Sep 2006, 16:18

07 Dec 2006, 17:07

While I'm at it, how about randomizing the monotonous slidshow that starts iterating through the same images?
Code
<?php

// Rename files with random names

$musicdir = @opendir("mp3"); 
	$cc = 0;
	while($filename = readdir($musicdir)) {
		if (ereg("\.mp3|\.MP3|\.jpg|\.JPG", $filename)) { 	
			$namearray[$cc] = "mp3/". $filename; $cc++; 
		}
	}

for ($i=0; $i<count($namearray); $i++) {
	$extension = strstr($namearray[$i], ".");
	$rndnm = "mp3/". rand(10,1000) . $extension;
	@rename($namearray[$i], $rndnm);
}

?>
Last edited by joey on 11 Dec 2006, 09:48, edited 1 time in total.
 
User avatar
Nick
Imagevue Hitman
Posts: 2872
Joined: 02 May 2006, 09:13

08 Dec 2006, 14:15

Hmm, interesting approach, but here is alternative suggestion - for getting mp3 tracks in random order every time just change in readfolder.php
Code
Line 25:
sort ($files);

to:
if ($ext=='mp3') shuffle($files); else sort ($files);
firedev.com
 
User avatar
globetrotter
Imagevue Expert
Posts: 844
Joined: 18 Oct 2006, 13:16

09 Dec 2006, 10:13

pain wrote:Hmm, interesting approach, but here is alternative suggestion - for getting mp3 tracks in random order every time just change in readfolder.php
Code
Line 25:
sort ($files);

to:
if ($ext=='mp3') shuffle($files); else sort ($files);
It works great!

In Firefox 2 you have an other song each page-refresh, and in IE6 every time you open the gallery in a new window.

Thanks Nick
Rene
http://www.globetrotternet.nl/
 
Hanky
Experienced
Posts: 90
Joined: 28 Nov 2006, 08:54

10 Dec 2006, 11:31

yes, it works really great - thanks to pain :P
greetings
hanky