I am trying to create an url to provide a video only one time. I will use that as an src for the video tag.
The idea is. Create an temporary and valid url. When the page is open I check if the page is valid (there is a temporary table with valid registers), get the data, delete the temporary register and open the file.
The problem is, if i delete the temporary register, after I get the data, the video streaming does not works.
It seems that it does not acts like a file descriptor, when, after it is open, even if i delete the node it keeps open.
The code that i am using is:
$temp=Temporaryvideo::model()->findByAttributes(array("video_id" => "$content", "hash" => "$key"));
if(count($temp)==1){
$video=Video::model()->findByPk($content);
$filename=$video->attributes['video_url'];
header('Pragma: public');
header('Expires: -1');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Cache-Control: private', false); // required for certain browsers );
header('Content-Type: video/mp4');
header('Content-Length: ' . filesize("videos/$filename"));
//$temp->delete();
readfile("videos/$filename");
}
That works fine until i delete the register from the database. Is there a way to make the url valid only once? I want to do that to avoid people from downloading the video. I know that there is other ways for them to get the video, but that will avoid some people to do that.
Changing the content-type to application/octet-stream solves that issue, but i cannot go forward or to the begin of the video.