JBoss.org Community Documentation

- Prev
- Next

## Chapter 29. MP3 Sequencer

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.

## 29.1. Example

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"

                  jcr:mixinTypes="mode:derived"

                  mode:derivedAt="2011-05-13T13:12:03.925Z"

                  mode:derivedFrom="/files/LOP.mp3"

                  mp3:title="Livin' on a Prayer"

                  mp3:author="Bon Jovi"

                  mp3:album="Slippery When Wet"

                  mp3:year="1986"

                  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")

          .usingClass("org.modeshape.sequencer.mp3.Mp3MetadataSequencer")

          .loadedFromClasspath()

          .setDescription("Sequences MP3 files to extract the ID3 tags of the audio file")

          .sequencingFrom("//(*.mp3[*])/jcr:content[@jcr:data]")

          .andOutputtingTo("/mp3s/$1");

- PrevChapter 28. Image Sequencer
- Top of page
- Front page
- NextChapter 30. DDL File Sequencer