Flash download mp3
- Started
- Last post
- 12 Responses
- designbot
Hello all,
I was hoping someone could help here....creating a flash site and I have a page with a bunch of "download" buttons to download mp3 audio files. Right now I am just using the following code to link people to the mp3's.
download10.onRelease = function() {
getURL("http://www.davidccook.co... "_blank");
};This will only play the file within a browser....I am used to html where a user could right click and say "download target as" to download the mp3, but since it's flash this is out of the question.
Is there a way to have them click the button and automatically start downloading the mp3 file?
Thanks for any help!
- fyoucher10
David Cook....hmmm.
- designbot0
ahh hey whatever....it's not david cook from american idol...lol.
- maximillion_0
send the name of the file to a php page as a GET or POST variable, pick it up with php $_GET or $_POST and then set the headers in the php page
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="example.mp3"');
header('Content-Transfer-Encodin... binary');other examples:
- Thanks for this! Is there a cold fusion equivalent?designbot
- cold fusion? holy year 2000!anxious_arms
- haha I know....ridiculous really. We are switching soon!designbot
- fyoucher10
Well, in that case I'll answer the question.
Check th FileReference Class in the Help section. That's ur answer for the download.
Then just create a custom right click menu for the movieclip. Check the ContextMenu class in the help section for that.
- designbot0
Thanks for the replies!
I found another solution which may be the easiest for anyone else looking to do the same....that is to zip up the files. Since the browser will not try and play them with the "zip" extension and will automatically prompt to download.
- blaw0
CF force download: http://lab.artlung.com/coldfusio…
- seems like what I need....how would I pull this into flash?designbot
- skt0
i just zip the fuckers up.
- but then i'm lazy.skt
- oh, i see you worked that one out already.skt
- then the user has to unzip, that's no usability solution at all.anxious_arms
- seems to be the easiest, and I really don't care about any extra trouble to the user :)designbot
- anxious_arms0
also, if you have a bunch of these buttons you should look into using XML and creating the buttons dynamically so you don't have to create all of them manually.
- skt0
i love how so many simple flash questions on here attract the 'you should use xml and as3 just like i do comments'. which is only slightly less irritating than the 'you should have used ajax instead of flash' comments.
i'm sure if someone is struggling with forced downloads, parsing xml will be a walk in the park.
- anxious_arms0
i'm sorry, SKT, that when I give advice I try to include best practices, try to save people time and encourage learning of a craft.
next time i'll suggest crayons and flash mx solutions.
- xml and embedded fonts aren't always best practice...skt
- i'm just saying that there is quite often an assumption that everyone is a developer and is fully up to speed.skt
- and unless it needs translated or there is a cms on the back, the end user doesn't give a shit if xml is in there or not.skt
- who said anything about embedding fonts? and if you have 10,000 buttons with refs to outside files, XML is best. ever updated a website?anxious_arms
- embedded / shared libraries, whatever. the boy asked for help on forced downloads and you told him to use xml.skt
- by the way designbot, make sure you use gotham narrow as your link font.skt
- designbot0
yeah...everyday I push to get a developer on my team, until then I am forced to hack my way through these issues :)
- mikotondria30
wow, I did exactly that this week on a site for a client of mine.
The mp3 file in question was for a different former winner of American Idol, I shit you not.!- Auto-fail!fyoucher1
- absolutely : )
I've done some work that involved people like this, literally cringing when I save documents with their names inmikotondria3 - documents with their names in the titles..mikotondria3