Name is required.
Email address is required.
Invalid email address
Answer is required.
Exceeding max length of 5KB

Cross domain policy restrictions


Hi, i am trying to play a video from my rackspace clould files account. If i mention the file url in the embade code, the video works perfectly. But i dont want to expose that url directly, so i am storing it in a database and trying to access it through an ID. If i specify that url which will fetch the video, i get a cross-domain policy restriction error even though the url points to the domain where the player.swf is placed. It perfectly plays the video from an other domain but cant access it through a file in the same domain. How do i fix this? Kindly help me. Thanks.

20 Community Answers

JW Player

User  
0 rated :

Here is the link for the player : http://www.googlewaveindia.com/shantanu/hazmat/video/api.php

I have placed a crossdomain.xml file under the root. Still i get error, Task Queue failed at step 5 could not load playlist Error: # 1088

Ethan Feldman

JW Player Support Agent  
0 rated :

According to FireBug, this file never finishes loading – http://www.googlewaveindia.com/shantanu/hazmat/video/streaming.php?ID=77I58mmm95893Hp525LE

I would set the “provide” flashvar to “video”

JW Player

User  
0 rated :

Is this how i set it so.addVariable('provider','video'); ? Kindly correct me if i am wrong. Thanks.

JW Player

User  
0 rated :

I set the provide flashvar as suggested, but now the player loads, but i get the message :
Video not found or access denied : http://www.googlewaveindia.com/shantanu/hazmat/video/streaming.php?ID=77I58mmm95893Hp525LE

Am i doing something wrong?

Ethan Feldman

JW Player Support Agent  
0 rated :

Okay, how is this script set up?

http://www.googlewaveindia.com/shantanu/hazmat/video/streaming.php?ID=77I58mmm95893Hp525LE

Please let me know, thanks.

JW Player

User  
0 rated :

Here is the code :

<?php


$ID = $_GET['ID'];
//Connect to MySQL database after sanitizing the data

$username = "*****";

$password = "****";

$hostname = "localhost";

$database = "******";

$dbhandle = mysql_connect($hostname, $username, $password)

or die("Unable to connect to MySQL");

//select a database to work with

$selected = mysql_select_db($database,$dbhandle)

or die("Could not select $database");

//Escape variables for use in MySQL

$ID = mysql_real_escape_string(stripslashes($ID));

// sending query

$result = mysql_query("SELECT `realurl` FROM `video` WHERE `id`='$ID'")

or die(mysql_error());

// store the record of the "example" table into $row

$row = mysql_fetch_array( $result )

or die("Invalid query: " . mysql_error());

// Print out the contents of the entry

$direction = $row['realurl'];

//close the connection

$path='http://'.$direction;

header('Content-type: video/mp4');

header('Content-Length: '.filesize($path)); // provide file size

header("Expires: -1");

header("Cache-Control: no-store, no-cache, must-revalidate");

header("Cache-Control: post-check=0, pre-check=0", false);

readfile($path);

mysql_close($dbhandle);

?>

Ethan Feldman

JW Player Support Agent  
0 rated :

Okay, for example … what does the ID 77I58mmm95893Hp525LE equal? What video file?

JW Player

User  
0 rated :

Its the id for the path of a video file. Here is the direct path : http://c0022138.cdn1.cloudfiles.rackspacecloud.com/video.mp4

Only "c0022138.cdn1.cloudfiles.rackspacecloud.com/video.mp4" is stored in the database as "http://" is appended in the code.

Instead of exposing the url directly, i am trying to access it from the database. Thanks.

Ethan Feldman

JW Player Support Agent  
0 rated :

Hmm…it seems to be that the db is not referencing the file correctly.

JW Player

User  
0 rated :

You mean there could be a mistake in the url stored in the db?

Ethan Feldman

JW Player Support Agent  
0 rated :

Yes, possibly.

JW Player

User  
0 rated :

If i place the direct url, it works perfectly. Is there some sample code, where the source is loaded through a script? Kindly help please. Thanks.

Ethan Feldman

JW Player Support Agent  
0 rated :

Sorry, I need to see both examples, can you show them?

JW Player

User  
0 rated :

Here is the code for http://www.googlewaveindia.com/shantanu/hazmat/video/api.php
bc.. <html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
<title>Untitled Document</title>
</head>
<body>
<h3>Player Example</h3>
<p>Below you see a simple embedded example of the JW Player. Copy and paste the source code and put the SWF, JS and FLV file on your site to get started.</p><!-- START OF THE PLAYER EMBEDDING TO COPY-PASTE -->
<script src="swfobject.js" type="text/javascript"></script>
<div id="mediaspace">This text will be replaced</div>
<script type="text/javascript">
var so = new SWFObject('player.swf','ply','800','480','9','#000000');
so.addParam('allowfullscreen','true');
so.addParam('allowscriptaccess','always');
so.addParam('wmode','opaque');
<?php
$path = "http://www.googlewaveindia.com/shantanu/hazmat/video/streaming.php?ID=77I58mmm95893Hp525LE";

?>
so.addVariable('file','http://c0022138.cdn1.cloudfiles.rackspacecloud.com/video.mp4');
so.addVariable('provider','video');
so.write('mediaspace');
so.addVariable('bufferlength','5');

</script><!-- END OF THE PLAYER EMBEDDING -->
</body>
</html>



in this file if for the file parameter, a direct url is given, it works perfectly. But if send the url through a variable like $path, it fails.

Code for http://www.googlewaveindia.com/shantanu/hazmat/video/streaming.php :
bc.. <?php
//Validate text input
/*
if (! preg_match('//^[-a-z.-@,'s]*$/i',$_GET['ID']))
{
die('Invalid name proved, the name may only contain a-z, A-Z, 0-9, "-", "_" and spaces.');
}
else
$empty=strlen($_GET['ID']);
if ($empty==0)
{
die('The text field cannot be empty');
}
else

{

//the input data is clean, retrieve text data input

$ID = $_GET['ID'];

}
*/
$ID = $_GET['ID'];
//Connect to MySQL database after sanitizing the data

$username = "rockline_video";

$password = "*****";

$hostname = "localhost";

$database = "rockline_video";

$dbhandle = mysql_connect($hostname, $username, $password)

or die("Unable to connect to MySQL");

//select a database to work with

$selected = mysql_select_db($database,$dbhandle)

or die("Could not select $database");

//Escape variables for use in MySQL

$ID = mysql_real_escape_string(stripslashes($ID));

// sending query

$result = mysql_query("SELECT `realurl` FROM `video` WHERE `id`='$ID'")

or die(mysql_error());

// store the record of the "example" table into $row

$row = mysql_fetch_array( $result )

or die("Invalid query: " . mysql_error());

// Print out the contents of the entry

$direction = $row['realurl'];

//close the connection

$path='http://'.$direction;

header('Content-type: video/mp4');

header('Content-Length: '.filesize($path)); // provide file size

header("Expires: -1");

header("Cache-Control: no-store, no-cache, must-revalidate");

header("Cache-Control: post-check=0, pre-check=0", false);

readfile($path);

mysql_close($dbhandle);

?>



In this file, i am just retrieving the complete url for the ID sent. What would be the best way to send the source of the file with out exposing the url? Thanks for all the help.

Ethan Feldman

JW Player Support Agent  
0 rated :

Hi,

I am Not sure what you are doing wrong, but Flash is not able to consume the content coming out of your php though.

If you download the file your script (http://www.googlewaveindia.com/shantanu/hazmat/video/streaming.php?ID=77I58mmm95893Hp525LE) it’s not a valid video file. I think that is the issue here.

-Ethan

JW Player

User  
0 rated :

Hmmmmmmm could you point me to some sample code where the source is passed to the player through some script?

JW Player

User  
0 rated :

And i was trying to hide the url from the source. Nothing more. So tried to pass it through a script.

Ethan Feldman

JW Player Support Agent  
0 rated :

Sorry, I don’t know of any scripts like this.

JW Player

User  
0 rated :

Okay. Thanks.

Ethan Feldman

JW Player Support Agent  
0 rated :

Np.

This question has received the maximum number of answers.