Jump to content

fread() an flv file causes php to hang


bslavinator

Recommended Posts

I need to have an swf player access a hidden flv file externally. I don't want the location revealed to the user, so I'm using fread() with the flv file to send that data to the flash player. This part works fine and the flv is loaded in properly.

 

$path = 'files/video.flv';
$total = filesize($path);
$sent = 0;
$blocksize = (1 << 20);
$handle    = fopen($path, "r");
               
while($sent < $total){
     $buffer = fread($handle, $blocksize);
     print $buffer;
     $sent += $blocksize;
}

 

My issue is that the flv files are between 70-100MB so the loop that 'streams' the data in usually takes quite a while. While this loop is executing, I cannot run other php functions. For example, if the user closes the window containing the flash player, the loop continues in the background and causes php to hang.

 

Is there a way that I could have the loop check for global variables or session variables to see if the user has closed the swf window? Or is there another way to abort a loop? Is there a way I could run this loop in the background and then have some sort of foreground process cancel it?

 

I'm reasonably new to file reading with PHP so I'm not quite sure how it handles memory and all that.

 

Thanks.

Link to comment
https://forums.phpfreaks.com/topic/151161-fread-an-flv-file-causes-php-to-hang/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.