CodeIgniter Forums
bypass controller and modify headers for flv output - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: bypass controller and modify headers for flv output (/showthread.php?tid=11935)



bypass controller and modify headers for flv output - El Forum - 09-29-2008

[eluser]alectrash[/eluser]
I want to have on my site the url

www.mydomain.com/video/view/a-lake

which upon being requested basically does this

Code:
//query db to get filename and filesize where file id is "a-lake" (simple)

      echo 'header("Content-Type: video/x-flv")';
      echo 'header("Content-Disposition: attachment; filename="' . $filename . '")';
      echo 'header("Content-Length: "' . $filesize .')';

When this is working in another file I want to send the url to a jeroenwijering player like so:

Code:
...
  s1.addVariable("file", encodeURIComponent(http://www.mydomain.com/video/a-lake));
...

I am storing videos above root directory hence why i'm doing it this way.

I tried creating a controller video with function view which output the headers but they just came out as text. I looked at kaging but to no avail.

I tried looking at hooks but dont know if thats right place to look?


bypass controller and modify headers for flv output - El Forum - 09-29-2008

[eluser]GSV Sleeper Service[/eluser]
a) make sure you're not sending any other output before the headers.
b) check your webserver config to make sure it knows what to do with video/x-flv

[edit] scrap that, I didn't notice that you were using echo to set the headers!


bypass controller and modify headers for flv output - El Forum - 09-29-2008

[eluser]Dready[/eluser]
Hello,

don't use "echo" to send your headers :

Code:
header("Content-Type: video/x-flv");
header("Content-Disposition: attachment; filename=\"$filename\"");
header("Content-Length: " . $filesize .")";



bypass controller and modify headers for flv output - El Forum - 09-30-2008

[eluser]Phil Sturgeon[/eluser]
To make sure there is nothing output already, best to clear the output buffer.

Code:
while (@ob_end_clean());
    
    header("Content-Type: video/x-flv");
    header("Content-Disposition: attachment; filename=\"$filename\"");
    header("Content-Length: " . $filesize .")";
    
    echo $whatever;

    die();