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?
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.
I would POSSIBLY think of using AJAX (if I couldnt think of another way)... and DEFINATELY not a frame
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.
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