Mon, 09/18/2006 – 3:03pm — ches

Updated for Drupal 5.1! See the bottom of the article.

I have a growing backlog of stories that I’ve been meaning to type up
here, including several articles of interest for folks getting started
with drupal, but I’ve just finished setting up the audio module, so I thought I’d share my experience while it’s fresh on the mind.

You’ll notice that you can now play the “two out of three” mp3 from my last post
direct from the site without the need to download, and this is thanks
to the audio module. Since it utilizes drupal’s node model for content
types, this module is able to harness much of the power and flexibility
inherent in the CMS, including the taxonomy system and automatic RSS/podcast feed generation. It can also be readily extended through modules like the playlist toolkit for sites with sophisticated audio needs.

My intent here, though, is just to offer a quick step-by-step guide
for a simpler application: a blog or some other site seeking to include
audio files attached to other content types (pages and stories, for
instance). Still, this should be helpful for anyone getting started with
the audio module.

Installation and Configuration

  1. Let’s obtain the audio module from the project page. I’m using version 4.7.0 for this guide. Untar the file in your site’s modules directory.

    > tar xzvf audio-4.7.0.tar.gz

  2. Next we need to download the getid3 PHP libraries and unzip the downloaded file into the same directory as audio.module.

    &gt; unzip getid3-1.7.7.zip -d <em>&lt;yoursitepath&gt;</em>/modules/audio/

    Version 1.7.7 of getid3 is recommended in the audio module’s documentation.

  3. Open the site in your browser and go to administer >> modules. Enable the audio, audio_attach and audio_getid3 modules. I don’t need to add audio files in bulk or use cover art, so I don’t use audio_import or audio_images. Configuration for those modules is not covered here.
  4. I don’t want audio entries in my navigation menu, so I disabled “audio” and “browse by” at administer >> menus. You can optionally enable audio-related blocks at, you guessed it, administer >> blocks.
  5. You’ll need to set user privelages according to your needs: at administer >> access control I gave my blog user “create audio” and “edit own audio” permissions in addition to the defaults.
  6. In order to attach audio nodes to other content types, we need to enable this capability for each type at administer >> settings >> content types. I first configured audio, disabling Attach Images and Attachments since I have the image_attach and upload modules enabled. I also disabled comments and promotion to front page. Then, enable Attach audio files for the content types that suit your needs. I did so for story. You might do the same for page, CCK types or others.
  7. Finally, check your settings at administer >> settings >> audio.
    Typical PHP configurations will default to a 2MB upload limit — you’ll
    probably need to adjust your php.ini as suggested if you haven’t
    already done so. Disable Downloadable by default if you want to make it more difficult for users to save copies of your music. Check that settings on the metadata tags tab are to your liking, and check the getid3 tab to assure that your installation is detected correctly.
  8. That’s it! You should now be able to create a new node — of a type
    set up in step six — with the option to attach an audio file. This will
    create an audio node behind the scenes, which you can browse (and edit
    id3 tags for) at yoursite.com/audio. If you don’t want this behavior,
    uncheck Published when attaching the audio file to your node.

Taking it Further

Of course, if audio plays a more prominent role at your site, there’s
much more that you can do with the audio module, incorporating
taxonomy, changing the look of the player, and so on. Here are some
links to get you started.

Update for Drupal 5.1

For the most part, updating my audio module for use as outlined above was intuitive, with one exception: the audio_attach module has just been contributed to CVS for 5.x by zirafa. He’s also contributed a new audio_playlist module, but I haven’t tried that out yet. To get audio_attach (and get my existing nodes with attached audio back to working order), I checked out the audio module from CVS with the following commands:

&gt; cd <em>&lt;yoursitepath&gt;</em>/modules<br />&gt; cvs -z6 -d:pserver:anonymous:<a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;&#97;&#110;&#111;&#110;&#121;&#109;&#111;&#117;&#115;&#64;&#99;&#118;&#115;&#46;&#100;&#114;&#117;&#112;&#97;&#108;&#46;&#111;&#114;&#103;">anonymous@cvs.drupal.org</a>:/cvs/drupal-contrib checkout -d audio contributions/modules/audio

I installed the modules as normal and ran update.php. At this point I
received an SQL error as the script attempted to set multiple primary
keys for the audio_attach table. I manually set nid, aid and weight as primary keys using phpMyAdmin, and I was back in business. I’ve found that my Flash players are not visible when using the handy admin_menu module, but that probably shouldn’t effect many of your users.

I’ll try to update all of these instructions soon. In the meantime, comment if you have questions!

One Response to drupal’s audio module
  1. Hello, I was just searching the inretnet and stumbled upon this nice website. I would like to let the webmaster know that they are doing a great job with this site. I am also trying to develop my own website as well. Unfortunately, things aren’t going so well, but I do not understand much about web development. I have tried really hard, but things just aren’t working for me. I have been using wordpres and doing the best that I can though. If someone has knowledge of web design and cares to give me any tips, I would love to here them. My website is here: My site is actually not a online pharmacy, it is just a blog about them. Thank You and I would greatly appreciate any comments.


[top]

Leave a Reply

电子邮件地址不会被公开。 必填项已用*标注