streaming mp3 files without allowing download

S

Sunfire

I need to be able to stream mp3 files, but refuse to let the visiter be able
to download them or get to them except from the page they are hosted at. Any
ideas how I would get started doing this?
 
B

bruce barker

you will need a browser plugin that implements this feature with
matching server code. the most common is flash.

-- bruce (sqlwork.com)
 
L

Lloyd Sheen

Sunfire said:
I need to be able to stream mp3 files, but refuse to let the visiter be
able to download them or get to them except from the page they are hosted
at. Any ideas how I would get started doing this?

No matter what method you use remember there are many programs available
that will capture the audio played on a workstation. If you are protecting
your own work then I can only suggest that you stream only a part of the
file as a sample, otherwise it is relatively easy to capture the output and
write it to a file in many formats.

LS
 
L

Lloyd Sheen

Sunfire said:
I need to be able to stream mp3 files, but refuse to let the visiter be
able to download them or get to them except from the page they are hosted
at. Any ideas how I would get started doing this?

I have an idea you might want to try. I just changed a site to dynamically
create images. They needed text to be super imposed on the button and did
not (could not) create all the possible button combinations. To do they I
created an aspx page that takes a querystring with the text and then streams
that to the response. You could possibly create a GUID for each song which
would last the duration of one stream. Pass that as the querystring (hold
the filename in session) and the page can then determine the filename and
stream the info to the response. Use the dynamic page as the url for the
streaming mp3 and while they would be able to see the url using properties
or IE dev toolbar, the URL would no longer work since the GUID would no
longer work.

If you need an example of this (the image example) please respond to this
msg.

Hope this helps
Lloyd Sheen
 
S

Sunfire

I am interested in trying it... I would need a step by step tutorial on it
though...
 
L

Lloyd Sheen

Sunfire said:
I am interested in trying it... I would need a step by step tutorial on it
though...

Ok:

First you create an new aspx page. Ensure there is nothing on the page (not
even a space) or that will be rendered as well.

On the page load:

Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
Dim imageFolder As String
Dim imageText As String
Dim bm As Bitmap
Dim ms As MemoryStream

imageFolder = Request.QueryString(imFolder)
imageText = Request.QueryString(imText)

If imageFolder Is Nothing Then
bm = makeImage(imageText)
Else
bm = makeImage(imageFolder, imageText)
End If

ms = New MemoryStream
bm.Save(ms, ImageFormat.Jpeg)
Response.ContentType = "image/jgp"
Response.BinaryWrite(ms.ToArray())
End Sub

Now my sample code is streaming a bitmap but what you would do is read the
mp3 file into the Memory stream from the file. Content type is
"audio/mpeg3".

An example of the link would be mymp3page.aspx?linkid=generatedGUID

You would then get the RequeestQueryString("linkid") to get the GUID and use
that to find which mp3 you want to stream. I know this is not well
presented but I may have time later to come up with a "real" set of code.
What I have offered works for jpg links.

Hope this gets you on your way
Lloyd Sheen
 
S

Sunfire

Can I get this put into C#? I don't know alot about VB and can't really
recode it into that. I can read it and understand it somewhat but... And is
this code supposed to be put on only 1 blank aspx page? There are a few more
questions I have to try and understand this:

1. If I have a link to the mp3, say <a href="audio/song1.mp3">Song 1</a>,
Would this code be able to interpret that?
2. Can I have other controls on the page that loads the mp3? Like a master
page or maybe volume up/down buttons and stuff?
thanks for the help...
Ok:

First you create an new aspx page. Ensure there is nothing on the page (not
even a space) or that will be rendered as well.

On the page load:

Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
Dim imageFolder As String
Dim imageText As String
Dim bm As Bitmap
Dim ms As MemoryStream

imageFolder = Request.QueryString(imFolder)
imageText = Request.QueryString(imText)

If imageFolder Is Nothing Then
bm = makeImage(imageText)
Else
bm = makeImage(imageFolder, imageText)
End If

ms = New MemoryStream
bm.Save(ms, ImageFormat.Jpeg)
Response.ContentType = "image/jgp"
Response.BinaryWrite(ms.ToArray())
End Sub

Now my sample code is streaming a bitmap but what you would do is read the
mp3 file into the Memory stream from the file. Content type is
"audio/mpeg3".

An example of the link would be mymp3page.aspx?linkid=generatedGUID

You would then get the RequeestQueryString("linkid") to get the GUID and use
that to find which mp3 you want to stream. I know this is not well
presented but I may have time later to come up with a "real" set of code.
What I have offered works for jpg links.

Hope this gets you on your way
Lloyd Sheen
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,521
Members
44,995
Latest member
PinupduzSap

Latest Threads

Top