1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Help me pls

Discussion in 'PHP & Perl' started by kinxlord, Dec 4, 2013.

  1. kinxlord

    kinxlord Registered Member

    Joined:
    Nov 18, 2010
    Messages:
    76
    Likes Received:
    27
    Location:
    Istanblue
    Home Page:
    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 :
    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>';
        
    }  
     
  2. rutix

    rutix Junior Member

    Joined:
    Sep 6, 2012
    Messages:
    102
    Likes Received:
    12
    that is something you need to configure in the player... where is the code for player list?
     
  3. kinxlord

    kinxlord Registered Member

    Joined:
    Nov 18, 2010
    Messages:
    76
    Likes Received:
    27
    Location:
    Istanblue
    Home Page:
    I don't think that all of them can be configured from player, btw I made html5 player using mediaelementjs. com.
    Edit

    Using mysql and I did it. Thanks .
     
    Last edited: Dec 6, 2013
  4. barigain

    barigain Junior Member

    Joined:
    Aug 23, 2012
    Messages:
    100
    Likes Received:
    12
    If you want something that doesn't easily make the URL known (or even to have an encrypted stream), you're going to have to go with a flash-based player like:
    http://www.longtailvideo.com/players/jw-flv-player/
    There are ways to obfuscate the URL to make the MP3 slightly more difficult to find, but ultimately, even with encrypted streams, there are tools out there to grab and save the data as it streams.