Jukebox that grabs from a PHP file

Posted on 2009-02-14
Last Modified: 2013-12-12
I need to build an interface that allows a user to upload an mp3 file and then be able to view their uploaded song through a Flash based jukebox.

Right now, I've got most of the "pieces" to this puzzle assembled and / or figured out. I've got a Flash Jukebox grabbing mp3 files from an XML file that I'm writing using PHP. It works great, but the problem is that I want to somehow pass a variable to this PHP / XML page that dictates from where in the database it's getting its info and I can't figure it out.

Right now, they click on a link and it goes to this Jukebox that's reading from songInfo.php. The php page will grab from the database the appropriate song titles, but how am I going go pull that off?

If the link to the Jukebox is jukebox.php, how do I embed in that link info that can then be passed on to songInfo.php? I want jukebox.php to be nothing more than a jukebox. In other words, I want the link to the Jukebox to be jukebox.php?id=4 and then the id is somehow passed to the songInfo.php file where it's drawing the song info from the database based on the id which is "4." That's what I want to do. How?
Question by:brucegust
    LVL 5

    Expert Comment

    I am not quite sure I understand the question completely but if you want a variable to be available to other PHP scripts you could use SESSION variables.  See the following links regarding sessions...
    LVL 2

    Expert Comment

    Is it the PHP script or the flash script that will process this list of titles? I see several ways of doing this

    1. Have the flash-player collect the list with a href like songinfo.php?id=4. The exact details I wouldn't know as I never learned to use flash.

    2. Make a function (or class) in the songinfo.php script that will return the songlist. Then you do an include("songinfo.php") and call the function inside the jukebox.php script. (Example: getTitles(4);)

    3. Use javascript to call additional files into the page (like the songinfo.php). This would be what is called AJAX.

    If you need to collect the title-list repeatedly without reloading the page (jukebox.php) you would need to use method 1 or 3. On the other hand, if you need to collect this list only once, method 2 makes more sense. It would be faster as you have one less file to collect for the web browser.

    There are probably other ways I have not thought about yet :P

    Author Comment

    The thing is, the Flash file will always be looking for songInfo.php. I can't hope to embed anything within that URL because it won't be picked up within the Flash application. Right?

    So, then I'm thinking I will script the songInfo.php file to pull from the database based on a session variable. So, from the catalog description, I'll have my user click on a link that will read something like jukebox.php?id=4. That page will be a resized window that takes the id and establishes it as a session id. That session id will be picked up by songInfo.php within the script and THAT's how I'll do it.

    I haven't tried this, yet. Does that sound like a good approach?
    LVL 5

    Accepted Solution

    It sounds like you are on the right track for using session variables however make sure that sessions are enabled in PHP and you use the session_start() command appropriately as the tutorial I pointed you to states. You don't really have to pass the variable in the URL either, I would have a link or button that when pressed sets the session variable and then loads the jukebox, also, since you are passing the variable to the jukebox already with ?id=4 then you could just use the $_GET['id'] variable in your jukebox script instead of the session variable.
    Let me know if this makes sense or not, if you want to post some code showing how the jukebox script is working I could probably modify it so you can see an example.

    Featured Post

    What Security Threats Are You Missing?

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    The Client Need Led Us to RSS I recently had an investment company ask me how they might notify their constituents about their newsworthy publications.  Probably you would think "Facebook" or "Twitter" but this is an interesting client.  Their cons…
    Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
    In this tutorial viewers will learn how to create a basic motion tween animation in Flash Open a new document in Flash: Draw/import an image: Press CTRL + F8 to convert it into a graphic symbol: Select a frame (how long you want the tween to last): …
    The goal of the tutorial is to teach the user how to select the video input device. Make sure you have an input device that in connected and work and recognized by Adobe Flash Media Live Encoder and select it in the “video input” menu.

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now