Solved

Flash mp3 Player / php track page / Javascript integration

Posted on 2006-07-05
7
265 Views
Last Modified: 2012-06-27
Hi there.
I currently have a php page that querys a database then lists information on 10 mp3s. Also on the page is an flash mp3 player that plays each of the mp3s listed on the page in turn. The information on the mp3's is loaded into the mp3 player using flashvars, turned into an array, so when each track finishes playing a new one is loaded.
What I would like to do is when an mp3 track is playing in the mp3player, that track is hightlighed in the php page in some other text colour. The idea of using javascript is so I do not have to refresh the page. Is this possible to achieve with javascript?
If I am barking up the wrong tree, please let me know. Any help is much appreciated.
Just to add, I know nothing about javascript other than it runs client side.

Many Thanks,
Mr Candu
0
Comment
Question by:mrcandu2
  • 3
  • 3
7 Comments
 
LVL 7

Expert Comment

by:geordie007
ID: 17041120

i don't think you're barking up the wrong tree, unfortunately i don't know enough about flash to comfirm that! is it possible for flash to call a javascript function that resides on the same page as the flash movie? if so, the theory would be this...

as you loop over your php/mysql recordset you include an id on each of the mp3 links. as the flash pays a track, it would call a javascript function on the page, passing the flashvar of the track as a parameter (for example changeTrack('crazy.mp3')). the function would match up that parameter with the tracks id, and change it's color to the highlighted color:

document.getElementById('crazy').style.color = '#ff0000';

as you use your php to write the tracks out, you could also populate a javascript array to contain all the track id's. in this way, the changeTrack function would first look through all of the id's, making sure they're all *not* highlighted, and then highlight the track passed as the parameter/argument.

hope this is some help to you - sorry i don't know enough about flash to be a bit more specific.
0
 
LVL 63

Expert Comment

by:Zvonko
ID: 17041246
What you are searching for is the getURL() method in Flash:

    getURL("javascript:highLight('rowID');")


If you have problems writing the highLight() JavaScript function, then post the page html source here.

0
 

Author Comment

by:mrcandu2
ID: 17043052
Many thanks geordie007 & Zvonko for your help, I am away from my computer at the momment, but will be sure to try out your suggestions when I am home. I will keep you posted on how it goes.
Many Thanks,
Mr Candu
0
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 

Author Comment

by:mrcandu2
ID: 17050162
Ok...... Yes I am having problems writing the javascript function. I have posted some basic code below that we can work on for this example. So what I need is to add the function that will change a row id's text colour when told to by the flash mp3 player using the command: getURL("javascript:highLight('rowID');")
Many thanks in advance.
Mr Candu.


<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<table width=400 cellspacing=0 cellpadding=0 border=0>
<tr id="trackID1">
    <td width=50> <a href="page?play=trackID1">1</a></td>
    <td width=250><a href="page?play=trackID1">Track Name 1</a></td>
    <td width=100><a href="page?play=trackID1">Track Genre 1</a></td></tr>
<tr id="trackID2">
    <td width=50> <a href="page?play=trackID2">2</a></td>
    <td width=250><a href="page?play=trackID2">Track Name 2</a></td>
    <td width=100><a href="page?play=trackID2">Track Genre 2</a></td></tr>
<tr id="trackID3">
    <td width=50> <a href="page?play=trackID3">3</a></td>
    <td width=250><a href="page?play=trackID3">Track Name 3</a></td>
    <td width=100><a href="page?play=trackID3">Track Genre 3</a></td></tr>
<tr id="trackID4">
    <td width=50> <a href="page?play=trackID4">4</a></td>
    <td width=250><a href="page?play=trackID4">Track Name 3</a></td>
    <td width=100><a href="page?play=trackID4">Track Genre 3</a></td></tr>
</table>
</body>
</html>
0
 
LVL 63

Accepted Solution

by:
Zvonko earned 125 total points
ID: 17050257
Here an example:

<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style>
TR.playing {
  background-color: silver;
}
</style>
<script>
var xRow;
function highLight(rowID){
  if(xRow) xRow.className="";
  xRow = document.getElementById(rowID);
  xRow.className="playing";
}
</script>
</head>
<body>
<a href="javascript:highLight('trackID1')">T1</a>
<a href="javascript:highLight('trackID2')">T2</a>
<a href="javascript:highLight('trackID3')">T3</a>
<a href="javascript:highLight('trackID4')">T4</a>
<table width=400 cellspacing=0 cellpadding=0 border=0>
<tr id="trackID1">
    <td width=50> <a href="page?play=trackID1">1</a></td>
    <td width=250><a href="page?play=trackID1">Track Name 1</a></td>
    <td width=100><a href="page?play=trackID1">Track Genre 1</a></td></tr>
<tr id="trackID2">
    <td width=50> <a href="page?play=trackID2">2</a></td>
    <td width=250><a href="page?play=trackID2">Track Name 2</a></td>
    <td width=100><a href="page?play=trackID2">Track Genre 2</a></td></tr>
<tr id="trackID3">
    <td width=50> <a href="page?play=trackID3">3</a></td>
    <td width=250><a href="page?play=trackID3">Track Name 3</a></td>
    <td width=100><a href="page?play=trackID3">Track Genre 3</a></td></tr>
<tr id="trackID4">
    <td width=50> <a href="page?play=trackID4">4</a></td>
    <td width=250><a href="page?play=trackID4">Track Name 3</a></td>
    <td width=100><a href="page?play=trackID4">Track Genre 3</a></td></tr>
</table>
</body>
</html>

0
 

Author Comment

by:mrcandu2
ID: 17050374
Well thats just amazing,......... it worked first time in IE and firefox.
Thanks Very Much.
0
 
LVL 63

Expert Comment

by:Zvonko
ID: 17050571
:-)
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Avoid defining the variables in the global scope; trying to define them in a local function scope. Because:   • Look-up is performed every time a variable is accessed.   • Variables are resolved backwards from most specific to least specific scope…
I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

776 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