0

I'm trying to build a workaround for embedding my (downloaded) flash videoplayer. (it's the JWplayer...)

At the moment, when somebody wants to embed the videoplayer they have to include the swf with all the added flashvars (ex: www.site.be/core/swf/player.swf?streamer=url&file=file.mp4&image=file.jpg&plugin=analytics...). That's messy, and it feels a bit risky... people who know what they are doing can also just remove the plugin and other added data, resolving in me not being able to track pageviews etc.

My workaround is like this:

$data = file_get_contents('URL');
header("content-type: application/x-shockwave-flash");
echo $data;

Turns out that, when I use file_get_contents on a regular test file, info.php, that responds through a $_GET['var'], the above stated code works, but when I use it on the flashplayer, it doesn't...

As in: the flash file does not seem to be accepting (or responding to) the added header variables...

Can somebody tell me why this is? Is this a 'flash' related problem or a 'Php' related problem? Or are there suggestions on how to handle my "flash-embed-with-to-much-junk"-problem in a different way?

(thanks)

1 Answers1

0

The flash is expecting GET parameters so you can't force them any other way.

What I would do is store the GET variables in a SESSION (called swf_vars in my example) if you want it a secret, then have the <embed> code point to a PHP script that does something like..

<?php
session_start();

// Full URL path to SWF
$url = "http://www.site.be/core/swf/player.swf?";

// These are the GET variables you want
foreach ($_SESSION['swf_vars'] as $key => $value) {
    $url .= $key . "=" . urlencode($value) . "&";
}

$url = rtrim("&", $url);

// Fetch the SWF
header("Content-Type: application/x-shockwave-flash");
echo file_get_contents($url);
?>
fire
  • 21,383
  • 17
  • 79
  • 114
  • that is what the workaround php-page is already doing, the problem is that this way the swf doesn't seem to accept the parameters. Like I said: Turns out that, when I use file_get_contents on a regular test file, info.php, that responds through a $_GET['var'], the above stated code works, but when I use it on the flashplayer, it doesn't... As in: the flash file does not seem to be accepting (or responding to) the added header variables... – Jasper Feb 10 '11 at 09:08
  • When you do file_get_contents are you using a full URL i.e. starting with http:// ? – fire Feb 10 '11 at 09:36