# Music library with download/play buttons

**URL:** https://forum.kirupa.com/t/music-library-with-download-play-buttons/182993
**Category:** Uncategorized
**Created:** [March 23, 2006, 12:44am UTC](https://forum.kirupa.com/t/music-library-with-download-play-buttons/182993 "2006-03-23T00:44:37Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![nightmusique](https://avatars.discourse-cdn.com/v4/letter/n/b9bd4f/32.png) [@nightmusique](https://forum.kirupa.com/u/nightmusique)
#### Post date: [March 23, 2006, 12:44am UTC](https://forum.kirupa.com/t/music-library-with-download-play-buttons/182993/1 "2006-03-23T00:44:37Z")

</div>

I am trying to create a music library on my website with about 100 songs that can be played and downloaded. I have difficulty finding tutorials related to what I am trying to do. I have created XML files with the songs’ names and files info. I am using attachMovie to create multiple instances of a movieClip that contains a dynamic text field for the title of the song and two buttons for download and play. I use getURL (file,"\_self")attached to the download button but it doesn’t work.Any suggestions ? Please  
here is the actionscript:

electro=new XML();  
electro.ignoreWhite = true;  
electro.onLoad = function (success){  
playlist=electro.firstChild.childNodes;  
for (i=0;i\<playlist.length;i++){  
name=playlist\*.attributes.name;  
link=playlist\*.attributes.file;  
this.TrackHolder=\_root.content.attachMovie(“songHold”,“mc”+i,i);  
this.TrackHolder.\_x=0;  
this.TrackHolder.\_y=i\*50;  
this.TrackHolder.Name.text=name;  
}  
}  
electro.load(“electro.xml”);

---

<div class="post-metadata">

### Author: ![azwebdesigns](https://avatars.discourse-cdn.com/v4/letter/a/8dc957/32.png) [@azwebdesigns](https://forum.kirupa.com/u/azwebdesigns)
#### Post date: [March 23, 2006, 3:57pm UTC](https://forum.kirupa.com/t/music-library-with-download-play-buttons/182993/2 "2006-03-23T15:57:14Z")

</div>

You can’t just download an audio file. Your browser will try to play it first with whatever player is associated with the file type your using. You can ‘zip’ your songs, then target the zip file with your download button. That will get the job done.  
**There are other ways** also but thats pretty easy. You can use a php file to download your songs also, let me explain.  
In any text editor (notePad) paste the following :

```auto
 
<?
Header( "Content-type: audio/x-mp3");
header("Content-Disposition: attachment; filename=\"".$HTTP_GET_VARS["f"] . ".mp3"."\"");
include($HTTP_GET_VARS["f"] . ".mp3");
?>

```

**call it ‘download.php’**

Then code your buttons like this:

```auto
 
on (release) {
getURL("download.php?f=song1");
}

```

Keep all the songs, flash and php files in the SAME directory! Or you can change the path if you want to.  
That’s it. Test it out!!

Now you can change the file type if it’s not an mp3. Other extensions would include:  
Header( “Content-type: image/jpeg”);  
Header( “Content-type: image/gif”);  
Content-type: application/pdf  
Content-Type: audio/x-wav  
Content-type: audio/x-mp3  
Content-Type: audio/mpeg  
Content-Typ: video/quicktime
