Implementing a download queue

Discussion in 'Programming' started by noodles, Apr 6, 2007.

  1. #1
    hey guys,

    i've started making a media player that is very similar to iTunes for a project... i now need to implement a download queue in php that allows the user to download music from the internet...

    any ideas on how to construct it? i was thinking a stack?
     
    noodles, Apr 6, 2007 IP
  2. ccoonen

    ccoonen Well-Known Member

    Messages:
    1,606
    Likes Received:
    71
    Best Answers:
    0
    Trophy Points:
    160
    #2
    well... any kind of collection-type would do...I think the tricky part would be to fire an event to move on to the next item in the array/stack/queue or whatever you program it in. I would maybe have a session hold the array, and maybe setup the site in frames - so you can have 1 frame that is always there - this frame would just refresh back to itself, detect if it needs to "init" the next item or not.
     
    ccoonen, Apr 6, 2007 IP
  3. Kalyse

    Kalyse Peon

    Messages:
    1,221
    Likes Received:
    24
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I would POSSIBLY think of using AJAX (if I couldnt think of another way)... and DEFINATELY not a frame :)
     
    Kalyse, Apr 6, 2007 IP
  4. sea otter

    sea otter Peon

    Messages:
    250
    Likes Received:
    23
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Well, the stack is only about 2% of "it" (the whole project), but if your question was specifically about whether a stack would work as a decent data structure here, then sure. In php stacks (and, for the purpose of what you need, linear queues as well) are just arrays, and you use the functions array_push(), array_pop(), array_shift(), array_unshift() to move things onto and off of the "stack" array.

    If necessary, you could also reorder the elements if the user wanted to change the order of their downloads, and you could also remove elements from the middle if they cancelled a download.
     
    sea otter, Apr 6, 2007 IP
  5. ccoonen

    ccoonen Well-Known Member

    Messages:
    1,606
    Likes Received:
    71
    Best Answers:
    0
    Trophy Points:
    160
    #5
    It is 100% impossible to keep consitent data regarding media - when frames are not used, or an external source. If you dind't have a frame... then every page load would restart the page. If you didn't have a popup... then every time you re-loaded the page, it would restart the song... just for your reference :)
     
    ccoonen, Apr 6, 2007 IP