This is a message.

PHP Variable to Java Script Created Jan 13, 2009

This thread is solved

Views: 9086     Replies: 5     Last reply Aug 7, 2011  
You must login first before you can use this feature

xcitan

Posts: 3

Registered:
Jan 13, 2009

PHP Variable to Java Script

Posted: Jan 13, 2009

Hi there,

i made an php file, that lists all available videos in a folder.
These Videos are listet and linked on the page.
If the link gets clicked there is a new site opened with forwarding the file name as parameter.
The player is included in the new page and should load the chosen video.

The forwarding of the parameter works fine and everything looks ok, but the player can`t load the video. It just shows "loading" all the time.

If i copy the html source code stated in the browser to a static html document everything works fine.

This is the URL:
http://esimple.de/example/index.php

Can you help me please?

Regards
Chris

This File includes the Flowplayer and it and looks exactly like that:

<html> <head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<script type="text/javascript" src="own.js"></script>
<link rel="stylesheet" type="text/css" href="style.css">
<title>Controlling Monitoring - Video Tutorials</title>
</head>
<body>
<div id="page">
$tutorial=$_GET["tutorial"];
echo $tutorial;
echo '
';
echo "
<script type="text/javascript">
var daten = "".$tutorial."";
";
?>
var map = {
clip: {
url: 'flv/'+daten,
autoPlay: false,
autoBuffering: true,
linkUrl: 'http://development.int.cinetic.de/dev_wiki/MediaFactory/ControllingMonitoring'
}
};
flowplayer("player", "flowplayer-3.0.2.swf", map);
</script>
</div>
</body>
</html>

xcitan

Posts: 3

Registered:
Jan 13, 2009

» PHP Variable to Java Script

Posted: Jan 13, 2009

Reply to: PHP Variable to Java Script, from xcitan
Maybe i should have used another topic.
because this
PHP Variable to Java Script
doesn`t really describe my Problem.

The PHP Variable works fine in Java Script.
But the player doesn`t load the file and i don`t know why.

Sorry for my poor english. ^^

Virgil

Posts: 18

Registered:
Nov 25, 2008

» » PHP Variable to Java Script

Posted: Jan 13, 2009

Reply to: » PHP Variable to Java Script, from xcitan
The problem is you're using a relative path to your video in the configuration, and Flash is trying to load the following URL:http://esimple.de/example/play-tutorial.php/flv/tutorial_wf_archetype_subtitled.avi.FLV

Note the PHP script in there.

Change your FlowPlayer configuration to have the full URL and it will probably work. If you want the page to be fully portable, use PHP to generate the URL based on the request.

xcitan

Posts: 3

Registered:
Jan 13, 2009

» » » PHP Variable to Java Script

Posted: Jan 13, 2009

Reply to: » » PHP Variable to Java Script, from smith186
Hi Virgil,

first of all thank you for your reply.
Unfortunately i don`t really understand why flash should try to load the full URL because i thought flash would use the path i configure.
Like:
a href="flv/'.$tutorial.'" style="display:block;width:800px;height:630px" id="player"

I did another try:
If i define the Variable including the name of the flv directly in the php file it works perfectly ($tutorial="tutorial_wf_archetype_subtitled.avi.FLV";).


<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
	<script type="text/javascript" src="own.js"></script>
	<link rel="stylesheet" type="text/css" href="style.css">
	<title>Controlling Monitoring - Video Tutorials</title>
</head>
<body>
<div id="page">
<?php 
$tutorial="tutorial_wf_archetype_subtitled.avi.FLV";
echo $tutorial;
echo '<a href="flv/'.$tutorial.'" style="display:block;width:800px;height:630px" id="player">
</a>';
?>
</a>
<script>
flowplayer("player", "flowplayer-3.0.3.swf", "flv/"); 
</script> 
</div>
</body>
</html>

If i try to GET the Name of the file by forwarding as parameter from the former page it doesn`t work. I can print out the content of the variable, but the player just won`t play it ($tutorial=$_GET["tutorial"];).


<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
	<script type="text/javascript" src="own.js"></script>
	<link rel="stylesheet" type="text/css" href="style.css">
	<title>Controlling Monitoring - Video Tutorials</title>
</head>
<body>
<div id="page">
<?php 
$tutorial=$_GET["tutorial"];
echo $tutorial;
echo '<a href="flv/'.$tutorial.'" style="display:block;width:800px;height:630px" id="player">
</a>';
?>
</a>
<script>
flowplayer("player", "flowplayer-3.0.3.swf", "flv/"); 
</script> 
</div>
</body>
</html>

I don`t understand the Problem.

Regards
Christian

Liam Gooding
Custom swf skins, custom swf plugins, custom JS plugins, video CMS - http://goodingsmedia.com

Posts: 352

Registered:
Dec 16, 2008

» » » » PHP Variable to Java Script

Posted: Jan 13, 2009

Reply to: » » » PHP Variable to Java Script, from xcitan
As PHP is purely server-side and javascript is purely client side, you can be safe in the thought that all your javascript is executed AFTER all PHP.

So this means the following would appear IDENTICAL to your javascript:


<?php
$content = "hello world";
?>
<p><?=$content;?></p>


<p>Hello World</p>