Solved

Flash mp3 Player / php track page / Javascript integration

Posted on 2006-07-05
7
262 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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 

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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Summernote and form validation 10 42
json with xmlhttprequesr 2 34
JavaScript error 1 33
Cordova Camera plugin fails 2 21
When you need to keep track of a simple list of numbers or strings, the Array object is your most direct tool.  As we saw in my earlier EE Article (http://www.experts-exchange.com/A_3488.html), typical array handling might look like this: (CODE) B…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
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…

760 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

20 Experts available now in Live!

Get 1:1 Help Now