Page 1 of 2

Playing MP3 Issue

Posted: Fri Sep 15, 2006 8:55 pm
by Bigun
I thought I had successfully found a way to play MP3's from a site and keep it from being downloadable.

Code: Select all

header('Content-Type: audio/mpeg');
header("Content-Disposition: attachment; filename=$newfilename");
readfile("$filepath");
Ignore the code above, read below

Played fine in Linux with mplayer...

But a friend of mine said it was an awful short song... like 3 seconds....

I booted into Windows.... sure enough.... it played 3 seconds and stopped...

Didn't play at all in IE.

Here's a link:
http://www.cybergrunge.com/play.php?song=13

Posted: Sat Sep 16, 2006 2:58 am
by andym01480
Don't you just need to <embed> to prevent it from being saveable?

Code: Select all

<EMBED    SRC="filename.mp3" HEIGHT=60 WIDTH=144>
http://www.htmlcodetutorial.com/embedde ... EMBED.html

Posted: Sat Sep 16, 2006 6:12 am
by Bigun
People can still look at the source and find the file...

The MP3's in question are stored in a directory that apache gives restricted access to. PHP has to readline it from that directory to the listener's audio player.

Posted: Sat Sep 16, 2006 7:35 am
by n00b Saibot
I just now saved that whole mp3 file - 8.07 MB - servo.hatred :)

anything that reaches client side can be saved on his computer... it can be mp3, flash, video, audio, css, virtually any thing that is served to client. you can make the job tough but not impossible...

in this case i'd suggest a flash player for your mp3.. just to harden the case...

Posted: Sat Sep 16, 2006 7:58 am
by andym01480

Code: Select all

header('Content-Type: audio/mpeg');
header("Content-Disposition: attachment; filename=$newfilename");//this line allows the save!
readfile("$filepath");

loose the content disposition header
When Internet Explorer receives the header, it raises a File Download dialog box whose file name box is automatically populated with the file name that is specified in the header. (Note that this is by design; there is no way to use this feature to save a document to the user's computer without prompting him or her for a save location.)

Code: Select all

header('Content-Type: audio/mpeg');
readfile("$filepath");
Opens it straight to your default mp3 player

Posted: Sat Sep 16, 2006 9:13 am
by Bigun
Whoops.... my bad... I pasted the code from my download.php.... not play.php:

Code: Select all

header('Content-Type: audio/mpeg');
readfile("$filepath");

Posted: Sat Sep 16, 2006 9:13 am
by Bigun
n00b Saibot wrote:I just now saved that whole mp3 file - 8.07 MB - servo.hatred :)

anything that reaches client side can be saved on his computer... it can be mp3, flash, video, audio, css, virtually any thing that is served to client. you can make the job tough but not impossible...

in this case i'd suggest a flash player for your mp3.. just to harden the case...
Even still, doesn't the flash player code contain the path of the MP3?

Posted: Sat Sep 16, 2006 10:45 am
by Bigun
I also have a .htaaccess file with the following in it:

Code: Select all

deny from all
When the applet loads up it can't access the file (duh)

You see the delima I'm in

Posted: Sat Sep 16, 2006 12:10 pm
by nickvd
Bigun, If you need to send it to the client... the client can save the file... the only (possible) way to prevent it would be embedding the mp3 with some sort of (yuk!) DRM...

Posted: Sat Sep 16, 2006 12:18 pm
by n00b Saibot
Bigun wrote:
n00b Saibot wrote:I just now saved that whole mp3 file - 8.07 MB - servo.hatred :)

anything that reaches client side can be saved on his computer... it can be mp3, flash, video, audio, css, virtually any thing that is served to client. you can make the job tough but not impossible...

in this case i'd suggest a flash player for your mp3.. just to harden the case...
Even still, doesn't the flash player code contain the path of the MP3?
like I said... you can make the job tough but not impossible...

Posted: Sat Sep 16, 2006 12:40 pm
by Bigun
:?

Damned if I do... damned if I don't

Posted: Sat Sep 16, 2006 2:35 pm
by Todd_Z
Why not just shorten the file length, that way you

a.) give a sample instead of the whole song
b.) save bandwidth which can get chewed up very fast with large files getting downloaded all the time

Posted: Mon Sep 18, 2006 8:32 am
by Bigun
I went with the flash player idea... if someone wants to go through that much trouble without signing up for a free account, more power to them.

Posted: Mon Sep 18, 2006 9:13 am
by Todd_Z
Gotta balance time with how much you care!

Posted: Mon Sep 18, 2006 8:59 pm
by Bigun
GUH!

It seems while I am trying to play MP3's using this button player it just stops playing the MP3 when it feels like.

See if it happens to anyone else:


http://www.cybergrunge.com/view.php?viewband=b-9