Jukebox that grabs from a PHP file

Posted on 2009-02-14
Medium Priority
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
  • 2

Expert Comment

ID: 23642648
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...

Expert Comment

ID: 23642683
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

ID: 23655749
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?

Accepted Solution

motley74 earned 2000 total points
ID: 23656103
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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The last time I worked with Flash and Socket connections was in AS1. A recent project required flash connecting to a Socket, and sending receiving information - we figured it would be easy enough - we all know about the socket policy documents and c…
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
In this tutorial viewers will learn how to create a basic shape tween animation in Flash including shape hints for smooth animation Open a new document in Flash: Draw a shape: Select another frame (how long you want the tween to be): Right click and…
The goal of the tutorial is to teach the user what frame rate is, how to control it and what effect it has on the video.
Suggested Courses
Course of the Month13 days, 18 hours left to enroll

807 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