javascript audio

I wracked my brain for a whole day but I did it! I added audio to Jack Dougherty's leaflet storymap.

To do this:

  1. Open your terminal and cd to the leaflet-storymap directory

  2. Make a new folder for audio files mkdir audio

  3. Add your audio files to this new folder

  4. Open script.js

  5. Underneath the var source code add

      var audio = $('<audio></audio>', {
        src: feature.properties['audio'],
        controls: 'controls',
        preload: 'auto',
      });
  6. Then, below the variables append audio to the container: container.append(chapter).append(image).append(source).append(audio).append(description);

  7. Open data.geojson

  8. After your "source-link" add "audio": "audio/yourfile.mp3"

  9. Done!

It is not perfect. It is just a simple audio control that needs to have some stylistic adjustments. Also, I would rather have a glyphicon play/pause. I will update once I get that going. But for now, audio is functioning!