Current location: Hot Scripts Forums » Programming Languages » PHP » media file streaming with php urls


media file streaming with php urls

Reply
  #1 (permalink)  
Old 08-28-06, 08:49 AM
Rollo Tamasi Rollo Tamasi is offline
Newbie Coder
 
Join Date: Jun 2006
Posts: 28
Thanks: 0
Thanked 0 Times in 0 Posts
media file streaming with php urls

I have a script at the moment which forces the user to download an mp3 instead of being able to stream it from the website.

Is it possible to have a url such as .php?file=5455 which can be used to stream?

Sorry if i didn't explain that too well
Reply With Quote
  #2 (permalink)  
Old 08-28-06, 10:17 AM
aLf_bl aLf_bl is offline
New Member
 
Join Date: Dec 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Yes it is!

Get this flash based mp3 player:
http://www.jeroenwijering.com/?item=Flash_MP3_Player

And then code:

PHP Code:

<?php

$mp3 
$_GET['mp3'];
?>
and where you want to show your player use thos code:

PHP Code:

<embed src="mp3player.swf?file=<? echo $mp3 ?>" quality="high" name="mp3player" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" align="" height="20" width="300"></p>
(I asume that you have stored mp3player.swf file in dir of page)

then you can access and stream audio like this:

Code:
index.php?mp3=path_to_mp_file.mp3
I hope I have helped you!
Reply With Quote
  #3 (permalink)  
Old 08-28-06, 12:34 PM
UnrealEd's Avatar
UnrealEd UnrealEd is offline
Community Liaison
 
Join Date: May 2005
Location: Antwerp, Belgium
Posts: 3,165
Thanks: 4
Thanked 25 Times in 25 Posts
that's not exactly what Rollo Tamasi wants , i think

Rollo Tamasi wants a script that hides the file that needs to be downloaded for the user:
PHP Code:

$files = ("file_path/myfile1.mp3""file_path/myfile2.mp3""etc.");

$file $files[$_GET['file']];
header("Content-type: application/mp3");
header("Content-disposition: attachment; filename=new_name.mp3");
header("Content-length: ".filesize($file));
readfile($file); 
in the $files array you must store all paths to the correct file. this script will then use the file variable in the url to select, by array-id, the correct file, and will open a download-window.
a link to download the files will look like this:
Code:
<a href="download.php?file=0">myfile1.mp3</a>
<a href="download.php?file=1">myfile2.mp3</a>
<a href="download.php?file=2">etc</a>
this is just a basic example, i'm using a database instead of an array where i store my filepaths.
UnrealEd
__________________
"Good judgement comes from experience, and experience comes from bad judgement." - Fred Brooks

Reply With Quote
  #4 (permalink)  
Old 08-28-06, 01:18 PM
Rollo Tamasi Rollo Tamasi is offline
Newbie Coder
 
Join Date: Jun 2006
Posts: 28
Thanks: 0
Thanked 0 Times in 0 Posts
that's exactly what i wanted UnrealEd, thanks very much
Reply With Quote
  #5 (permalink)  
Old 11-27-06, 01:06 AM
TheNixMaster TheNixMaster is offline
Newbie Coder
 
Join Date: Oct 2006
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
How can I read the headers to see if its a direct access to the mp3 (like from the flash player or winamp) and then make it so the link player.php?file=da8s83kd will play in the player.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
including php file within html albobis PHP 4 06-12-06 10:15 PM
Checking a file exists lee PHP 3 04-23-06 12:44 AM
PHP - Unable to remove items from a file AdrianLewis PHP 5 03-17-06 05:14 AM
Using PHP Echo in ASX Media Files sixflagsga PHP 8 02-16-06 01:56 PM
PHP Downside--Solutions? Amulet PHP 10 07-15-05 08:26 AM


All times are GMT -5. The time now is 07:27 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.