CodeIgniter Forums
Loading an MP3 file through php validation for "streaming" in flash player - 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: Loading an MP3 file through php validation for "streaming" in flash player (/showthread.php?tid=15920)



Loading an MP3 file through php validation for "streaming" in flash player - El Forum - 02-18-2009

[eluser]amites[/eluser]
has anyone here done this?

I have setup a program to validate that a user has access to a given mp3 file, from there they have the options of downloading it or listening to it through a flash player that is designed to access the file directly through an HTTP protocol (not actual streaming)

The download part works well using:
Code:
<?php
header("Cache-Control: public, must-revalidate");
header("Pragma: hack"); // WTF? oh well, it works...
header("Content-Type: " . $mm_type);
header("Content-Length: " .(string)(filesize($file_path)) );
header('Content-Disposition: attachment; filename="'.$file_name.'"');
header("Content-Transfer-Encoding: binary\n");

readfile($file_path);

?>
however I have had one hell of a time getting it to load into a mp3 player, I figure it has something to do with the "Content-Transfer-Encoding" though I'm honestly in a bit over my head at this point.

any thoughts / advice / help / examples / etc...

thank you


Loading an MP3 file through php validation for "streaming" in flash player - El Forum - 02-19-2009

[eluser]pistolPete[/eluser]
What mp3 swf player are you using? any popular one?
I am using CI's helpers:
Code:
(...)
$this->load->helper('file');
$this->load->helper('download');
force_download($data['filename'],read_file('./mp3/'.$data['filename']));
(...)

This works for downloading and http "streaming" to the swf player.


Loading an MP3 file through php validation for "streaming" in flash player - El Forum - 02-19-2009

[eluser]amites[/eluser]
I appreciate the advice, still not getting this working though

currently looks like

Code:
$this->load->helper(array('file', 'download'));
            force_download($m['name'], read_file($file));

echo of $m['name'] = Test 1

echo of $file = D:\Web-Sites\Heritage Web Design\Erik Ohanessian\hidden\mp3\01-Joe-Satriani-Not-Of-This-Earth.mp3
(this is a real file I can open in Firefox directly)

tried it with and without the read_file, comes up blank when I open the page

any ideas?


Loading an MP3 file through php validation for "streaming" in flash player - El Forum - 02-19-2009

[eluser]pistolPete[/eluser]
Try the filename without space.
Try a relative path instead of the absolute one.
Try php native functions like readfile just to check if you have access to the file.


Loading an MP3 file through php validation for "streaming" in flash player - El Forum - 02-19-2009

[eluser]amites[/eluser]
Not sure why the helper didn't want to work for me, though ti did give me the template for a file_stream view that does work,

thank you!

for general reference:

Code:
<?php
    header('Content-Type: "application/octet-stream"');
    header('Content-Disposition: attachment; filename="'.$file_name.'"');
    header("Content-Transfer-Encoding: binary");
    header('Expires: 0');
    header('Pragma: no-cache');
    header("Content-Length: ".filesize($file_path));

    readfile($file_path);
?>