kinxlord
Registered Member
- Nov 18, 2010
- 89
- 37
Hi guys. It's nearly 3 a.m. here and I feel kinda tired but I want to finish my project today.
So I'm coding a mp3 listining script. It's simple one. Mp3's are fetched from file. First I used this :
But thn I don't want user to click and start playing the song because there will be alot of mp3s. So What I want to do shuffle player. Whenever user refresh the page random song starts from the file and when song is finished another random song starts. I hope I could explain it. I'm still working on it, I know I'm doing something wrong. Someone can help me ?
So I'm coding a mp3 listining script. It's simple one. Mp3's are fetched from file. First I used this :
PHP:
//if not in ignore list create a link if(!in_array($curfile, $ignore)) { echo "<li><a href='?file=".$curfile."'>$curfile</a></li>\n "; } }
//if file selected if(isset($_GET['file'])){
//get selected file $file = $_GET['file'];
But thn I don't want user to click and start playing the song because there will be alot of mp3s. So What I want to do shuffle player. Whenever user refresh the page random song starts from the file and when song is finished another random song starts. I hope I could explain it. I'm still working on it, I know I'm doing something wrong. Someone can help me ?
PHP:
<?php //set folder to read from $dirname = "music/";
//read files in folder $files = scandir($dirname); shuffle($files); //ignore hidden files $ignore = Array(".", "..");
//loop through all files foreach($files as $curfile){
}
//if file selected if(isset($_GET['file'])){
//get selected file $file = $_GET['file'];
//player pass in the path to the file echo ' <div class="player"> <audio id="player" src="'.$dirname.$file.'" type="audio/mp3" autoplay="1"></audio> </div>';
}