This topic is locked
[SOLVED]

 Variable in javascript/script to play flash videos

4/19/2010 10:41:53 AM
PHPRunner General questions
C
copper21 author

Hey all,
Looking to play video using the view page in PHPRunner 5.2. I have been sucessful in doing this, but only by what I would call doing it statically. This is what I have done thus far. I have created a simple table with the following fields: "title" and "video_script". "Title" is just the title of the video and "video_script" is the script to play the flash video. I have "video_script" simply setup as text and when I go to add a record, I put the script into it, which then plays a video on the view page; it is setup as 'view HTML' as well. Here is the script:
<script type='text/javascript' src='http://SERVERNAME/videofiles/swfobject.js'></script>;
<div id='mediaspace'>This text will be replaced</div>
<script type='text/javascript'>

var so = new SWFObject('http://SERVERNAME/videofiles/player.swf','mpl','700','500','9';);

so.addParam('allowfullscreen','true');

so.addParam('allowscriptaccess','always');

so.addParam('wmode','opaque');

so.addVariable('file','videoname.flv');

so.addVariable('streamer','rtmp://FLASHSERVER/my_application/');

so.addVariable('controlbar','over');

so.write('mediaspace');</script>
The fourth line from the bottom contains the file name of the video that is being played. Everytime I add a record, I enter this script into the "video_script" field and simply change the name of the video. My question to you is how can I always have this script and make the video name a variable so that I can just enter the video name and not the whole script everytime.
I hope that I have provided enough information; thanks all in advance for your assistance.

Sergey Kornilov admin 4/19/2010

I would suggest to store video file name only. Then set 'View as' type of this field to 'Custom' and use the following code:

$value = "<script type='text/javascript' src='http://SERVERNAME/videofiles/swfobject.js'></script>;
<div id='mediaspace'>This text will be replaced</div>
<script type='text/javascript'>

var so = new SWFObject('http://SERVERNAME/videofiles/player.swf','mpl','700','500','9';);

so.addParam('allowfullscreen','true');

so.addParam('allowscriptaccess','always');

so.addParam('wmode','opaque');

so.addVariable('file','" . $value . "');

so.addVariable('streamer','rtmp://FLASHSERVER/my_application/');

so.addVariable('controlbar','over');

so.write('mediaspace');</script>";
C
copper21 author 4/19/2010



I would suggest to store video file name only. Then set 'View as' type of this field to 'Custom' and use the following code:

$value = "<script type='text/javascript' src='http://SERVERNAME/videofiles/swfobject.js'></script>;
<div id='mediaspace'>This text will be replaced</div>
<script type='text/javascript'>

var so = new SWFObject('http://SERVERNAME/videofiles/player.swf','mpl','700','500','9';);

so.addParam('allowfullscreen','true');

so.addParam('allowscriptaccess','always');

so.addParam('wmode','opaque');

so.addVariable('file','" . $value . "');

so.addVariable('streamer','rtmp://FLASHSERVER/my_application/');

so.addVariable('controlbar','over');

so.write('mediaspace');</script>";


C
copper21 author 4/19/2010

Sergey,
Thanks again for your help; it worked wonderfully. For those of you out there interested in this, the only thing I had to add in the in the "custom" field before the script is:
$value = $data["videonamefield"];
Thanks!

S
siro 5/24/2010

what about Windows Medai player that code will work too