Wordpress to Octopress: Audio

Wordpress to Octopress

Another step on the migration from Wordpress to Octopress is to get the audio elements and embedded audio files to the new platform. Well, the files are quite simple, but to get some plugins playing nicely with them, is a different story.

After testing around with some of the many available plugins (like soundmanager2) and failing all time long I stumbled over audio.js. Again.

I remembered that I once was working on this specific problem a couple of months ago and I’ve already included the plugin into the theme.

A simple test confirmed it was working and so I’ve re-written the photo_tag-plugin from Devin Weaver again and created the plugin for replacing an audio-tag with the corresponding code.

It’s plain and simple.

  1. Add the audio.min.js file to your JavaScript folder.

  2. Include the code from the audio.js project into your Octopress installation by putting the JavaScript lines into your head.html (watch out for the correct paths here!)

    <script src="/javascripts/audio.min.js"></script>
     <script>
       audiojs.events.ready(function() {
         var as = audiojs.createAll();
       });
     </script>
    
  3. You’ll find the code below. Save it to a file <root>/plugins/audio_tag.rb and it should work.

One comment on that: I prefer to not automatically start the plugin to play when initialised. Therefore the parameter for the audio.js-plugin has been set to “none”. If you want it in an other way, replace the parameter:

preload="auto"