使用PHP读取流媒体链接,我想检测用户断开连接时的平均关闭播放器,以便我可以在断开时间时进行统计
然而似乎connection_aborted没有执行......
这是你的例子:
ob_end_clean(); //Clean (erase) the output buffer and turn off output buffering
ob_start(); // Turn on output buffering
ignore_user_abort(true); //TRUE ignores user aborts in a script
$file = "http://192.168.1.2:8000/hls/250.m3u8";
header("location: $file");
$fd = fopen($file, "r");
while(!feof($fd)) {
echo fread($fd, 1024 * 5);
ob_flush();
flush();
if (connection_aborted()){
//this part not executing...
$ManagerActiv->deleteClient_activity($activity);
break;
}
}
fclose ($fd);
exit();
die();
}