JBoss.orgCommunity Documentation

Chapter 28. MP3 Sequencer

28.1. Example

Another sequencer that is included in ModeShape is the modeshape-sequencer-mp3 sequencer project. This sequencer processes MP3 audio files added to a repository and extracts the ID3 metadata for the file, including the track's title, author, album name, year, and comment. After extracting this information from the audio files, the sequencer then writes this structure into the repository, where it can be further processed, analyzed, searched, navigated, or referenced.

This sequencer generates a node with the name mp3:metadata below the sequencing target. That is if the ouputtingTo property from the sequencer configuration is /mp3s/LivinOnAPrayer, the sequencer will output a node to /mp3s/LivinOnAPrayer/mp3:metadata.

<mp3:metadata jcr:primaryType="mp3:metadata"
              mp3:title="Livin' on a Prayer"
              mp3:author="Bon Jovi"
              mp3:album="Slippery When Wet"
              mp3:comment="Rock 'n' roll!" />

The CND used by this sequencer is provided below.

[mp3:metadata] > nt:unstructured, mix:mimeType
  - mp3:title (string)
  - mp3:author (string)
  - mp3:album (string)
  - mp3:year (long)
  - mp3:comment (string)

To use this sequencer, simply include the modeshape-sequencer-mp3 JAR and the JAudioTagger library in your application and configure the JcrConfiguration to use this sequencer using something similar to:

JcrConfiguration config = ...
config.sequencer("MP3 Sequencer")
      .setDescription("Sequences MP3 files to extract the ID3 tags of the audio file")