MOSTAGHASSI
asked on
How can i pass a file name path to this javascript on a cfm page?
Hello all,
On a page (playsong.cfm) i have this query and retieve a filed (trackfilepath)
which contain mp3 file name ,like track1.mp3 ,i want that pass the path (<location>) of
this file to the javascript below ,please let me know that how can i do it?
Thanks
<cfparam name="url.trackfilepath" default="">
<cfquery name="recordset1" datasource="musicarchiveDS " >
select trackfilepath
from tbTracks
where trackfilepath like '#url.trackfilepath#'
</cfquery>
<script type="text/javascript">
// <![CDATA[
var so = new SWFObject("ep_player.swf", "ep_player", "269", "226", "9",
"#FFFFFF");
so.addVariable("skin", "skins/nobius_platinum/ski n.xml");
so.addVariable("file",
"<location>http://localhost/magazine/musicarchive/songtracks/track1.mp3</locati
on><creator>Song Creator</creator><title>So ng Title</title>");
so.addVariable("autoplay", "false");
so.addVariable("shuffle", "false");
so.addVariable("buffertime ", "1");
so.write("flashcontent");
// ]]>
</script>
On a page (playsong.cfm) i have this query and retieve a filed (trackfilepath)
which contain mp3 file name ,like track1.mp3 ,i want that pass the path (<location>) of
this file to the javascript below ,please let me know that how can i do it?
Thanks
<cfparam name="url.trackfilepath" default="">
<cfquery name="recordset1" datasource="musicarchiveDS
select trackfilepath
from tbTracks
where trackfilepath like '#url.trackfilepath#'
</cfquery>
<script type="text/javascript">
// <![CDATA[
var so = new SWFObject("ep_player.swf",
"#FFFFFF");
so.addVariable("skin", "skins/nobius_platinum/ski
so.addVariable("file",
"<location>http://localhost/magazine/musicarchive/songtracks/track1.mp3</locati
on><creator>Song Creator</creator><title>So
so.addVariable("autoplay",
so.addVariable("shuffle", "false");
so.addVariable("buffertime
so.write("flashcontent");
// ]]>
</script>
are you trying to pass in some XML as a variable? if not, then there is no reason to have that mark up there.
just pass the url as teh variable.
can you further explain what you have working... and were the application fails.
rp
eeZAPE
just pass the url as teh variable.
can you further explain what you have working... and were the application fails.
rp
eeZAPE
ASKER
Thanks for your comments.
I have a folder that contain my mp3 files suppose 100 files from track1.mp3 to track100 this folder is Songtracks in coldfusion query i retieve the file name suppose track40.mp3 then i want put the path of this file in javascript codes that you see in part of <location> so all part of of codes are without any changing except the part of <location> so if i retieve track40.mp3 then the <location> must be :
<location>http://localhost/magazine/musicarchive/songtracks/track40.mp3</location>
and for track 23.mp3 e.g is:
<location>http://localhost/magazine/musicarchive/songtracks/track23.mp3</location>
so i must pass this file name in javascript as i mentioned above.
I have a folder that contain my mp3 files suppose 100 files from track1.mp3 to track100 this folder is Songtracks in coldfusion query i retieve the file name suppose track40.mp3 then i want put the path of this file in javascript codes that you see in part of <location> so all part of of codes are without any changing except the part of <location> so if i retieve track40.mp3 then the <location> must be :
<location>http://localhost/magazine/musicarchive/songtracks/track40.mp3</location>
and for track 23.mp3 e.g is:
<location>http://localhost/magazine/musicarchive/songtracks/track23.mp3</location>
so i must pass this file name in javascript as i mentioned above.
So you just want to pass the url like this?
<script type="text/javascript">
<cfoutput>
var #ToScript(recordset1.trackfilepath, "trackName")#;
</cfoutput>
// <![CDATA[
var so = new SWFObject("ep_player.swf", "ep_player", "269", "226", "9", "#FFFFFF");
so.addVariable("skin", "skins/nobius_platinum/skin.xml");
so.addVariable("file", "http://localhost/magazine/musicarchive/songtracks/"+ trackName);
so.addVariable("autoplay", "false");
so.addVariable("shuffle", "false");
so.addVariable("buffertime", "1");
so.write("flashcontent");
// ]]>
</script>
ASKER
Hi agx,
Yes, this is the things that i want ,but would you please write that line as compelet? my mean is this line below ,i put the sign of (") around http but the codes goes to gray color and not work.
"<location>http://localhost/magazine/musicarchive/songtracks/track1.mp3</locati
on><creator>Song Creator</creator><title>So ng Title</title>");
Yes, this is the things that i want ,but would you please write that line as compelet? my mean is this line below ,i put the sign of (") around http but the codes goes to gray color and not work.
"<location>http://localhost/magazine/musicarchive/songtracks/track1.mp3</locati
on><creator>Song Creator</creator><title>So
ASKER
I write like this and not above:
"<location> "http://localhost/magazine/musicarchive/songtracks/"+trackName</location>
<creator>Song Creator</creator><title>So ng Title</title>");
but the part of url goes to gray color,and cannot recognize the url,i have tested with putting paranteses around url also,ofcourse the cf tag is in my code as you have written:
<cfoutput>
var #ToScript(recordset1.track filepath, "trackName")#;
</cfoutput>
"<location> "http://localhost/magazine/musicarchive/songtracks/"+trackName</location>
<creator>Song Creator</creator><title>So
but the part of url goes to gray color,and cannot recognize the url,i have tested with putting paranteses around url also,ofcourse the cf tag is in my code as you have written:
<cfoutput>
var #ToScript(recordset1.track
</cfoutput>
ASKER
the complelet code that i write is this:
so.addVariable ("file",
"<location> "http://localhost/magazine/musicarchive/songtracks/"+ trackName
</location><creator>Song Creator</creator><title>So ng Title</title>");
so.addVariable ("file",
"<location> "http://localhost/magazine/musicarchive/songtracks/"+ trackName
</location><creator>Song Creator</creator><title>So
but you are still passing in what looks to be XML data... is this correct?
if so, then most likely your code in Flash is not parsing the XML correctly....
can you post the actionscript for me...
rp
eeZAPE
if so, then most likely your code in Flash is not parsing the XML correctly....
can you post the actionscript for me...
rp
eeZAPE
ASKER
Yes you are right ,but i don't have action script ,this problem is regarding sending that path of a mp3 file in a javascript and and then it call flash mp3 player, i want to buy it but i'm trying to test it first ,in javascript we can send a playlist.xml of only a file as you see above, as agx has written in coldfusion i must retieve the file name and the determine the path in javascript ,the solution of agx is right but around the variable is that there are this mark(") in trackname variable is e.g
trackname="Track2.mp3";; while i need that it be trackname=Track2.mp3 or as he has used + trackname but it does not detremine the right path.
trackname="Track2.mp3";; while i need that it be trackname=Track2.mp3 or as he has used + trackname but it does not detremine the right path.
MOSTAGHASSI,
The quotes " are just used to enclose the javascript variable name definition. The final string should not contain quotes. It should look like this. Is this not the correct path?
http://localhost/magazine/musicarchive/songtracks/Track2.mp
Two other options are
The quotes " are just used to enclose the javascript variable name definition. The final string should not contain quotes. It should look like this. Is this not the correct path?
http://localhost/magazine/musicarchive/songtracks/Track2.mp
Two other options are
<!--- option 1 --->
<script type="text/javascript">
<cfoutput>
var #ToScript("http://localhost/magazine/musicarchive/songtracks/#recordset1.trackfilepath#", "trackPath")#;
</cfoutput>
// <![CDATA[
var so = new SWFObject("ep_player.swf", "ep_player", "269", "226", "9", "#FFFFFF");
so.addVariable("skin", "skins/nobius_platinum/skin.xml");
so.addVariable("file", trackPath);
so.addVariable("autoplay", "false");
so.addVariable("shuffle", "false");
so.addVariable("buffertime", "1");
so.write("flashcontent");
// ]]>
</script>
<!--- option 2 --->
<script type="text/javascript">
// <![CDATA[
var so = new SWFObject("ep_player.swf", "ep_player", "269", "226", "9", "#FFFFFF");
so.addVariable("skin", "skins/nobius_platinum/skin.xml");
<cfoutput>
so.addVariable("file", "http://localhost/magazine/musicarchive/songtracks/#recordset1.trackfilepath#");
</cfoutput>
so.addVariable("autoplay", "false");
so.addVariable("shuffle", "false");
so.addVariable("buffertime", "1");
so.write("flashcontent");
// ]]>
</script>
ASKER
Yes ,but you omit a part of code i must write the compelet code inside the so.addVariable
the complete code is like below and it start with "file",<location> ,you omit the part of <location> that start before http
so.addVariable("file",
"<location>http://localhost/magazine/musicarchive/songtracks/track1.mp3</locati
on><creator>Song Creator</creator><title>So ng Title</title>");
istead of url that start with http if i write like this below it does not work and i must write the compelet code
so.addVariable("file",
"<location>"http://localhost/magazine/musicarchive/songtracks/#recordset1.trackfilepath#"</locati
on><creator>Song Creator</creator><title>So ng Title</title>");
you omit the part of <location> at the start of code,for path you are right but when i put between tag of <location> as above it does not work
the complete code is like below and it start with "file",<location> ,you omit the part of <location> that start before http
so.addVariable("file",
"<location>http://localhost/magazine/musicarchive/songtracks/track1.mp3</locati
on><creator>Song Creator</creator><title>So
istead of url that start with http if i write like this below it does not work and i must write the compelet code
so.addVariable("file",
"<location>"http://localhost/magazine/musicarchive/songtracks/#recordset1.trackfilepath#"</locati
on><creator>Song Creator</creator><title>So
you omit the part of <location> at the start of code,for path you are right but when i put between tag of <location> as above it does not work
I assume you enclosed it in cfoutput tags? Otherwise it won't evaluate #recordset1.trackfilepath# .
> so.addVariable("file",
> "<location>"http://localhost/magazine/musicarchive/songtracks/#recordset1.trackfilepath#"</locati
> on><creator>Song Creator</creator><title>So ng Title</title>");
Is that valid syntax for the object you're using? I would have thought it just accepted a url.
If you hard-code the information, does it work? If it doesn't work then its a problem with your syntax, not the CF code.
> so.addVariable("file",
> "<location>"http://localhost/magazine/musicarchive/songtracks/#recordset1.trackfilepath#"</locati
> on><creator>Song Creator</creator><title>So
Is that valid syntax for the object you're using? I would have thought it just accepted a url.
If you hard-code the information, does it work? If it doesn't work then its a problem with your syntax, not the CF code.
<!---
Verify the track path / url is correct
--->
<script type="text/javascript">
// <![CDATA[
var so = new SWFObject("ep_player.swf", "ep_player", "269", "226", "9", "#FFFFFF");
so.addVariable("skin", "skins/nobius_platinum/skin.xml");
so.addVariable("file", "<location>http://localhost/magazine/musicarchive/songtracks/Track2.mp3</location><creator>Song Creator</creator><title>Song Title</title>");
so.addVariable("autoplay", "false");
so.addVariable("shuffle", "false");
so.addVariable("buffertime", "1");
so.write("flashcontent");
// ]]>
</script>
ASKER
The code that you have written in the box work very well, but we need that instead of Track2.mp3 put the variable that contain the name of mp3 file ,and suppose that we come with Track2.mp3 to this .cfm page inside the trackname(that you have written between <cfoutput> tags) i see that there is like this:
Trackname="Track2.mp3";; (there are quote and semicolom) but if i have like this:
Trackname=Track2.mp3 i can put the Trackname instead of Track2.mp3 in the url .
Trackname="Track2.mp3";; (there are quote and semicolom) but if i have like this:
Trackname=Track2.mp3 i can put the Trackname instead of Track2.mp3 in the url .
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
No,the object bring the mp3 player but because cannot find the right path ,write message that error on loading mp3 file.
Ofcours on Toscript you have written "trackPath" and between <location> tags i think it must be trackPath and i put trackPath ,but it doesnot work,and the problem is regarding recognizing of path,because it works with e.g a track name like Track2.mp3
Ofcours on Toscript you have written "trackPath" and between <location> tags i think it must be trackPath and i put trackPath ,but it doesnot work,and the problem is regarding recognizing of path,because it works with e.g a track name like Track2.mp3
You mean it doesn't accept a javascript variable?
What happens if you omit the javascript variable entirely like this. Watch the line wrapping
What happens if you omit the javascript variable entirely like this. Watch the line wrapping
<script type="text/javascript">
// <![CDATA[
var so = new SWFObject("ep_player.swf", "ep_player", "269", "226", "9", "#FFFFFF");
so.addVariable("skin", "skins/nobius_platinum/skin.xml");
<cfoutput>
so.addVariable("file", "<location>http://localhost/magazine/musicarchive/songtracks/#recordset1.trackfilepath#</location><creator>Song Creator</creator><title>Song Title</title>");
</cfoutput>
so.addVariable("autoplay", "false");
so.addVariable("shuffle", "false");
so.addVariable("buffertime", "1");
so.write("flashcontent");
// ]]>
</script>
If that works, then I was right in my first comment :)
ASKER
Hi agx,
Your last solution before this one that i past below works and i had a mistake,sorry for this,and thanks a lot for this ,i appreciate .
<script type="text/javascript">
<cfoutput>
var #ToScript("http://localhost/magazine/musicarchive/songtracks/#recordset1.trackfilepath#", "trackPath")#
</cfoutput>
// <![CDATA[
var so = new SWFObject("ep_player.swf", "ep_player", "269", "226", "9", "#FFFFFF");
so.addVariable("skin", "skins/nobius_platinum/ski n.xml");
so.addVariable("file", "<location>"+ trackPath +"</location><creator>Song Creator</creator><title>So ng Title</title>");
so.addVariable("autoplay", "false");
so.addVariable("shuffle", "false");
so.addVariable("buffertime ", "1");
so.write("flashcontent");
// ]]>
</script>
Your last solution before this one that i past below works and i had a mistake,sorry for this,and thanks a lot for this ,i appreciate .
<script type="text/javascript">
<cfoutput>
var #ToScript("http://localhost/magazine/musicarchive/songtracks/#recordset1.trackfilepath#", "trackPath")#
</cfoutput>
// <![CDATA[
var so = new SWFObject("ep_player.swf",
so.addVariable("skin", "skins/nobius_platinum/ski
so.addVariable("file", "<location>"+ trackPath +"</location><creator>Song
so.addVariable("autoplay",
so.addVariable("shuffle", "false");
so.addVariable("buffertime
so.write("flashcontent");
// ]]>
</script>
<location>#trackfilepath#<