spikypunker Posted January 29, 2009 Share Posted January 29, 2009 hey guuyyys! Ok, have asked a few questios so far, am bulidng a small music sharing service for unsigned bands etc. I've got it all working sweet, just need to address how the mp3s are accessed. As a temp solution i simlpy have a button linking to them, this means that depending on the users setup they either are asked if they wanna download it or open with, or it opens straight with the person Quicktime etc. I'd like it so that one button automatically starts a download (or the open with/save as window) but always does this so that i can label it DOWNLOAD and it wont try and play it in Quicktime. Then i'd like to find some kind of universal solution to stream it so that there can be a second button, PLAY NOW. I'm getting more up on my Flash knowledge so could this be a good route? Just send the variable of the filename into a simple Flash movie wich then streams it? Or is there a free PHP based profgram which allows a variable to be sent into it (the filename of the track) and then plays it? Any thoughts or links to free software would make me happy! peace! Chris Link to comment https://forums.phpfreaks.com/topic/142958-mp3-file-handling/ Share on other sites More sharing options...
spikypunker Posted January 29, 2009 Author Share Posted January 29, 2009 hmm ok... I've found a good free player that runs usign flash and javascript http://www.schillmania.com/projects/soundmanager2/demo/template/ and this seems exactly what i need for the play bit. Now i just need to sort the download button out? I dont want to have to have a thing saying "Please right-click and save as" cause thats lame! So i just need to know the PHP function to start a download.....if there is one? Sounds like a virus risk????? hmmmmmmmm help! Link to comment https://forums.phpfreaks.com/topic/142958-mp3-file-handling/#findComment-749697 Share on other sites More sharing options...
ialsoagree Posted January 29, 2009 Share Posted January 29, 2009 I believe that sending this header should solve your problem: <?php header("Content-Type: application/force-download"); ?> There are probably other headers you need to send, such as: <?php header("Content-Type: application/octet-stream"); header("Content-Type: application/download"); header("Content-Description: File Transfer"); header("Content-Length: " . filesize($file)); ?> You can accomplish this "selective" force download using a GET condition. Have the link be something like: ./mp3file.php?mp3_id=[some ID]&download=1 Then just use an if statement to check for the get condition: <?php if (isset($_GET['download'])) { // send headers and force download } else { // let client or your flash player deal with the content itself } ?> Link to comment https://forums.phpfreaks.com/topic/142958-mp3-file-handling/#findComment-749752 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.