1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Embedded Mp3 Player that plays songs from a folder?

Discussion in 'Graphics & Multimedia' started by BlueLaw, Aug 16, 2008.

  1. #1
    Hi,

    Is this possible?...

    I have a folder online that is being controlled by a Content Management System. My client will add and remove Mp3's from that folder...

    Is it possible to have a player embedded in a web page that formulates its playlist from the songs folder?

    ie. when my client adds a song to the folder, it's added to the playlist, when he takes one away, it's removed?

    What do you think?
    :rolleyes:
     
    BlueLaw, Aug 16, 2008 IP
  2. ToddMicheau

    ToddMicheau Active Member

    Messages:
    183
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    58
    #2
    So this is in a web directory? Yea, it can be done easily- create a php script that scans the folder for all .mp3 files, then outputs their name and path in xml format. Load the xml (php) file with the flash player and run as usual. Most free players out there that load from an xml file can be modded to do this. And the php file would be rather easy to create.
     
    ToddMicheau, Aug 16, 2008 IP
  3. BlueLaw

    BlueLaw Guest

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Yes Todd!

    You know what I'm talking about! I've used .php scripts in the past, but I'm not going to lie to you, I wouldn't begin to know how to do this.

    I've been looking at the player "Neolao MP3 Player Multi" to be the flash player.

    and the uploads folder would be in this location:

    http://www.website.co.uk/uploads/sound/

    I'm always happy to read up on stuff, can you point me in the right location with this one?

    Thanks so much for your help so far, just glad it's possible.
    :)
     
    BlueLaw, Aug 16, 2008 IP
  4. ToddMicheau

    ToddMicheau Active Member

    Messages:
    183
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    58
    #4
    Well whatever flash player you use it has to load the playlist through an XML. If you could send me the link of the flash player you are going to use I will script the php file for you- but I need the link because I need to see a demonstration of the xml structure.

    =]

    (I've got experience with this kinda thing, check out http://mp3.bubblecoder.com/)
     
    ToddMicheau, Aug 16, 2008 IP
  5. BlueLaw

    BlueLaw Guest

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    This is where web design gets exciting!

    I was looking at this player:
    http://flash-mp3-player.net/players/multi/generator/

    The only reason I was interested in that one is you can customize it a little bit, so I was going to try and make it look a little less fugly. I am totally open to suggestion though.

    If you click Documentation, you can see that the player does accept XML for the use of multiplaying blah blah blah.

    Let me know what you think Todd!
     
    BlueLaw, Aug 16, 2008 IP
  6. ToddMicheau

    ToddMicheau Active Member

    Messages:
    183
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    58
    #6
    Here is the php code you will need, just save it as a php file (playlist.php) and put it in the folder with the mp3 files:

    
    <?
    function isMp3($filename){
    	$ext = substr($filename, -4);
    	if($ext == '.mp3'){
    		return true;
    	}else{
    		return false;
    	}
    }
    
    $d = dir(getcwd());
    while (false !== ($filename = $d->read())) {
    	if(isMp3($filename)){
    		$playlist .= $filename . '|';
    	}
    }
    $d->close();
    echo "mp3=" . substr($playlist, 0, strlen($playlist) - 1);
    ?>
    
    PHP:
    Then this is the code I used to test the php file, you can base yours from this- changing of course as you need:

    
    <html>
    <body>
    <div>
      <object type="application/x-shockwave-flash" data="http://www.bubblecoder.com/player_mp3_multi.swf" height=500 width=500>
      <param name="movie" value="http://www.bubblecoder.com/player_mp3_multi.swf" />
      <param name="wmode" value="transparent" />
      <param name="FlashVars" value="config=http://www.bubblecoder.com/test/playlist.php" />
      </object>
    </div>
    </body>
    </html>
    
    HTML:
    At http://bubblecoder.com/test/test.html

    Good luck~
     
    ToddMicheau, Aug 16, 2008 IP
  7. BlueLaw

    BlueLaw Guest

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    This is fantastic Todd, sorry I didn't get back to you earlier. But I had to go to the pub.

    Mine is almost working, it formulates the playlist, then doesn't play the songs. Any ideas?

    http://www.james-ashton.co.uk/test.html

    :confused:
     
    BlueLaw, Aug 17, 2008 IP
  8. BlueLaw

    BlueLaw Guest

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    I'm now wondering if this could be a server side problem?

    I have databases and php code working on the server, but could I be missing some technology that allows this to work?
     
    BlueLaw, Aug 17, 2008 IP
  9. 5ive

    5ive Well-Known Member

    Messages:
    1,348
    Likes Received:
    32
    Best Answers:
    0
    Trophy Points:
    185
    #9
    If im not wrong Yahoo has one player that will automatically do all this.
     
    5ive, Aug 17, 2008 IP
  10. newcity

    newcity Peon

    Messages:
    1,015
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    0
    #10
    You can use one of the free MP3 embed player. Google them , there are lots of em.
    Good luck!

    Thanks,
    SameerHosting.com
     
    newcity, Aug 17, 2008 IP
  11. wibblywobbly

    wibblywobbly Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #11
    Hi!

    I'm trying to continue where this guy left off...

    This is where I've got to:

    wibblywobblywebsite
    dot
    com
    /testzone/
    test.html

    This is using the scripts suggested by Todd (above) - as you can see, it generates the playlist, but the mp3's don't play!

    I have no coding knowledge really so I don't know where to go. Sorry to resurrect this old post, but it seems like a worthy cause to solve this.

    Thanks!
    - Wibbly

    PS: just to clarify! I want to create an embedded mp3 player, that plays ALL the songs from a folder located online. When I take a song out of the folder, the player automatically removes it from the playlist, when I add a song to the folder, the player automatically adds it. No cutting and pasting codes or anything, just uploading and deleting mp3 files from a folder on the web server...

    Thanks!
     
    wibblywobbly, Feb 5, 2009 IP
  12. caffeineromance

    caffeineromance Guest

    Messages:
    23
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #12
    I dont think its possible man...
     
    caffeineromance, Feb 6, 2009 IP
  13. wibblywobbly

    wibblywobbly Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #13
    Surely it is possible!

    The guy above seems to suggest it's easy and although his files have gone now it looks like he actually got it working as an example on his website.

    If you go to wibbly wobbly website dot (com) (/) testzone (/)test.html

    It has formulated the playlist, I just don't know why the songs don't play.

    Does everybody else think this isn't possible?
     
    wibblywobbly, Feb 7, 2009 IP
  14. wibblywobbly

    wibblywobbly Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #14
    I've got a little further with this.

    It IS possible. Using the scripts above, the player is looking for the MP3's in the same folder that the html is in.

    But I've put the MP3's in a folder called "/playlist" - and it's missing this part of the address out.

    I don't know scripting, can anyone tell me how to put a full file location into the PHP?

    so at the moment the PHP is generating the adress only as /
    But I need a full address /playlist
    - or even on a different website altogether

    <?
    function isMp3($filename){
        $ext = substr($filename, -4);
        if($ext == '.mp3'){
            return true;
        }else{
            return false;
        }
    }
    
    $d = dir(getcwd());
    while (false !== ($filename = $d->read())) {
        if(isMp3($filename)){
            $playlist .= $filename . '|';
        }
    }
    $d->close();
    echo "mp3=" . substr($playlist, 0, strlen($playlist) - 1);
    ?>
    Code (markup):
     
    wibblywobbly, Feb 8, 2009 IP
  15. wibblywobbly

    wibblywobbly Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #15
    Here's where I've got to now: The player is generating the playlist, but not playing the .mp3s. This is something to do with the way the PHP form specifies the locations of the .mp3s.

    I've tried changing the PHP from this:
    $d = dir(getcwd());
    Code (markup):
    To this:
    $d = dir("/testzone/playlist");
    Code (markup):
    This way I'm saying exactly where the location is.

    Sadly, this didn't work, and the player threw me an error message. I hate PHP, anyone have any suggestions?

    Thanks.
    -- Wibbly.
     
    wibblywobbly, Feb 11, 2009 IP
  16. steveljohn8

    steveljohn8 Peon

    Messages:
    47
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #16
    Yes it is possible but you will have to generate XML for creating play lists
     
    steveljohn8, Nov 2, 2009 IP
  17. Davidian

    Davidian Peon

    Messages:
    1
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #17
    Okay... so it actually works if you put the playlist.php file, player, and player.html file all in the same file as the MP3's.



    The only issue I have is.. I run a podcast, my podcast likes to change the file names once I have uploaded them, and the player uses the file names and not the meta tags.

    This is not a big issue really, just glad it works... shame I cannot order the playlist by newest first.. maybe I can...

    oh and wiblywobly

    instead of

    $d = dir("/testzone/playlist");
    PHP:
    try

    $d = dir("./testzone/playlist");
    PHP:
    However I think the most simple solution is to have everything in the same folder as thats what I had to do to get everything to work.

    you can see it working here if you like

    http://podcast.nexusradio.co.uk/media/player.html
    PHP:
     
    Davidian, May 17, 2011 IP