Hi Georgi,
It sounds like a time consuming task, packing video file should definitely be done
in background, in a separate thread so that it doesn't hang up the browser and also
so you can display a progress of this job. Yes, issue 15 [1] describes possible solutions
to your problem. Using ajax should be the simplest solution I think, you just load a
"pack_video.php?job_id=1" script with the XMLHttpRequest object [2] so that it runs in background
in a separate thread, you can find many examples on the web, this script may insert a record to a
database table called "video_job" with the job_id=1, this table should have a column named
"progress" that will be updated by the "pack_vide.php" script. Using ajax you can query this table
for the progress and display it to the user.
There is also possible an other solution that I have sometimes used, it doesn't require you to use
any ajax techniques. You need to disable output buffering, zlib compression or others in php settings,
so that when you echo a string it gets to the browser immediately, take a look at this example code:
ini_set('zlib.output_compression', 0);
ini_set('output_buffering', 0);
ini_set('implicit_flush', 1);
function fprint($s)
{
$args = func_get_args();
call_user_func_array('printf', $args);
ob_flush();
flush();
}
Now you can load the "pack_video.php" script in the browser, this script should output a string
that is a call to a javascript function that updates the progress bar using the "fprint" function:
<script>update_progress_bar(20%);</script>
Of course while this script executes user could click some link on the page and the php script
"pack_video.php" would be terminated, so it has its disadvantages compared to the ajax solution.
Cheers,
Czarek