Hi,
I want to stream a file in background of php file ???
In other words want to stream a file and do another jobs ???
Tnx.
Hi,
I want to stream a file in background of php file ???
In other words want to stream a file and do another jobs ???
Tnx.
Please answer me ? ;-(
Hi,
Tnx a lot for all.
I found solution. I used stream file but dont wait for response :
fwrite($this->agi->out, trim( "STREAM FILE $file \"\" 0" ) . "\n");
fflush($this->agi->out);
For repeat stream this file i got file duration with this function :
private function getDuration($file) {
$fp = fopen($file.'.wav', 'r');
$size_in_bytes = filesize($file.'.wav');
fseek($fp, 20);
$rawheader = fread($fp, 16);
$header = unpack('vtype/vchannels/Vsamplerate/Vbytespersec/valignment/vbits', $rawheader);
$sec = ceil($size_in_bytes/$header['bytespersec']);
return $sec;
}
So my code :
<?
$file = '';
$file_duration = getDuration( $file );
$start_time = time();
$stream = true;
while( 1 ) {
// Do another job in here
if ( $stream === true ) {
$start_time = time();
fwrite($this->agi->out, trim( "STREAM FILE $file \"\" 0" ) . "\n");
fflush($this->agi->out);
}
if( time() - $start_time > $file_duration ) {
$stream = true;
}
}
?>