Connecting Tech Pros Worldwide Forums | Help | Site Map

PHP and Flash movies

LL2000
Guest
 
Posts: n/a
#1: Jul 17 '05
Hello!

I'd like to allow users to upload Flash movies to my website and have
them displayed in a page.

There are certain things that I either need in order to display them
correctly, such as the version of Flash, the width/height of the movie, etc.

Does anyone know if there is any existing code available to do this?
Ideally, I would like to not ask for -anything- from the user, except
for the actual Flash movie.

Thanks for your help!

Chung Leong
Guest
 
Posts: n/a
#2: Jul 17 '05

re: PHP and Flash movies



"LL2000" <liquidN0SPAMlaughter2000@yahoo.co.uk> wrote in message
news:rhZZd.68946$ug2.45137@fe2.news.blueyonder.co. uk...[color=blue]
> Hello!
>
> I'd like to allow users to upload Flash movies to my website and have
> them displayed in a page.
>
> There are certain things that I either need in order to display them
> correctly, such as the version of Flash, the width/height of the movie,[/color]
etc.[color=blue]
>
> Does anyone know if there is any existing code available to do this?
> Ideally, I would like to not ask for -anything- from the user, except
> for the actual Flash movie.
>
> Thanks for your help![/color]

Here's something I wrote. Not terribly efficient or well written but works.

function ExtractSWFInfo($path) {
// read the data
$data = file_get_contents($path);

// signature
$sign = substr($data, 0, 3);
if($sign == 'CWS' || $sign == 'FWS') {

$compressed = ($sign{0} == 'C');
$version = ord($data{3});

// file length
extract(unpack('Vlength', substr($data, 4, 4)));

$data = substr($data, 8);
if($compressed) {
$data = gzuncompress($data);
}

// frame coordinates, first 5 bit is the number of bit per coord
$b = ord($data{0});
$nb = $b >> 3;
$bin = decbin($b & 0x07);
$bits = substr('000', 0, - strlen($bin)); // 0-padded
$bits .= $bin;

// read the bits
$index = 1;
for($bits_required = $nb * 4; $bits_required > 0; $bits_required -= 8) {
$bin = decbin(ord($data{$index++}));
$bits .= substr('00000000', 0, - strlen($bin));
$bits .= $bin;
}

// cut bitstring into four parts
$coord_bits = array();
for($i = 0, $j = 0; $i < 4; $i++, $j += $nb) {
$coord_bits[$i] = substr($bits, $j, $nb);
}

// convert from bin to integer
$coord = array();
for($i = 0; $i < 4; $i++) {
$num = bindec(substr($coord_bits[$i], 1));
if(substr($coord_bits[$i], 0, 1) == '1') {
$num = -$num;
}
$coord[$i] = $num;
}

// get the dimension in pixels
$width = round($coord[1] / 20);
$height = round($coord[3] / 20);

// frame rate and count
extract(unpack('Cframerate_decim/Cframerate/vframecount', substr($data,
$index, 4)));

return compact('compressed', 'length', 'version', 'width', 'height',
'framerate', 'framecount');
}
return false;
}

$file = "C:/Documents and Settings/cleong/Desktop/cow_test.swf";

var_dump(ExtractSWFInfo($file));




LL2000
Guest
 
Posts: n/a
#3: Jul 17 '05

re: PHP and Flash movies


Chung Leong wrote:[color=blue]
> "LL2000" <liquidN0SPAMlaughter2000@yahoo.co.uk> wrote in message
> news:rhZZd.68946$ug2.45137@fe2.news.blueyonder.co. uk...
>[color=green]
>>Hello!
>>
>>I'd like to allow users to upload Flash movies to my website and have
>>them displayed in a page.
>>
>>There are certain things that I either need in order to display them
>>correctly, such as the version of Flash, the width/height of the movie,[/color]
>
> etc.
>[color=green]
>>Does anyone know if there is any existing code available to do this?
>>Ideally, I would like to not ask for -anything- from the user, except
>>for the actual Flash movie.
>>
>>Thanks for your help![/color]
>
>
> Here's something I wrote. Not terribly efficient or well written but works.[/color]
<snip>

Thank you very much. That's perfect. You've saved me hours of work and
restored my belief in newsgroups :)

LL.
Closed Thread


Similar PHP bytes