Playing random videos from a folder?

Discussion in 'PHP' started by tanyania, Jun 20, 2011.

  1. #1
    Hey guys, I just finished installing flowplayer (video player for my website) on my server but I would like flowplayer to play random videos from a folder on my server everytime the page is refreshed. I have no idea how I could go about doing this. But I'm fairly certain it would involve some PHP, hence why I post my question here. If anybody can point me in the right direction it would be greatly appreciated.
     
    tanyania, Jun 20, 2011 IP
  2. darkowl

    darkowl Peon

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Hello tanyania,

    flowplayer reads a xml file to show videos. Hence you have to point it to a php that act like a xml file. I can't provide live links because I'm new here. But search google for php output as xml and you'll find plenty info.

    On that example it takes info from a database. In your case your "database" is a dir list. So you have a handy php function called readdir. search the php docs for it. Read the comments for a bucket load of examples.


    Hope it helps. I did not provide the live links because I'm new here :)
     
    darkowl, Jun 20, 2011 IP
  3. WiserX

    WiserX Peon

    Messages:
    16
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Hi...

    Use scandir() function to get the list of videos.

    $curVideoList = array_diff(scandir("relative video folder location"), array(".",".."));

    Choose a random value. Create a xml file as a string within the php, insert the random video location and output the xml with proper header. you must call this script from the player's embedded source.
     
    WiserX, Jun 20, 2011 IP