Solved

Flash mp3 Player / php track page / Javascript integration

Posted on 2006-07-05
7
267 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

This article shows how to create and access 2-dimensional arrays in JavaScript.  It includes a tutorial in case you are just trying to "get your head wrapped around" the concept and we'll also look at some useful tips for more advanced programmers. …
This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
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…

756 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