views:

138

answers:

3

I am trying to download mp3 file to users machine without his/her consent while they are listening the song.So, next time they visit that web page they would not have to download same mp3, but palypack from the local file. this will save some bandwidth for me and for them. it something pandora used to do but I really don't know how to.

any ideas?

+4  A: 

You can't forcefully download files to a user without his consent. If that was possible you can only imagine what severe security flaw that would be.

You can do one of two things:

  • count on the browser to cache the media file
  • serve the media via some 3rd party plugin (Flash, for example)
Yuval A
A: 

I have no experience with this, but you could try your luck with DOM storage in newer browsers:

  • IE8

  • FF>=2

  • Opera > 9.5, as I have read somewhere

  • Safari and Chrome should implement it, too, I guess

Here's an article by John Resig about that.

However, if questions contain something like 'without the user's knowledge' or 'without the user having to agree', typically the one asking really should reconsider his/her thoughts about the visitors and what is or isn't good for them.

Cheers,

Boldewyn
AFAIK - DOM Storage is not relevant for binaries...
Yuval A
Hm, that could be true. But if you have an HTML5 browser, you could store the base64 encoded file and feed that to a dynamically created `<audio>` element. Don't know, if *any* browser out there supports all of the necessary techniques, but according to the spec I think it should work.
Boldewyn
where are my backticks? The above comment should read ...created `<audio>` element...
Boldewyn
+2  A: 

Don't do this.

Most files are cached anyway.

But if you really want to add this (because users asked for it), make it optional (default off).

Gamecat
Just my line of thought. Don't force your users. +1
Boldewyn