mod_audio

Adds support for viewing and handling audio medium items.

This module parses audio files and extracts tags and an optional image from the audio file.

Note

mod_audio uses the command-line utilities ffmpeg and ffprobe. For mod_audio to function correctly they must be present in the search path of Zotonic.

Uploading

The audio module hooks into the media model to intercept any audio file upload.

If an audio file is uploaded then the file is parsed using ffprobe to fetch:

  • The bitrate
  • Audio duration
  • Tags, like artist, album
  • Album art image, extracted as png using ffmpeg

The optional album art is used as the preview image. This image is visible when the audio media item is rendered using a {% image ... %} tag.

Viewing

The audio module extends the {% media %} tag for viewing audio/* videos.

It uses the template _audio_viewer.tpl for viewing.

Editing

The following properties are extracted from the audio file, and can be edited in the admin:

  • artist
  • album
  • album_artist
  • composer
  • genre
  • track
  • copyright
  • is_compilation (boolean flag)
  • org_pubdate, this is extracted form the creation_time tag

If there is no resource title given when creating the audio page then the title from the tags is used. If that one is empty then the file’s basename is used.

Accepted Events

This module handles the following notifier callbacks:

  • observe_media_upload_props: Set medium properties from the uploaded file using z_media_archive:abspath.
  • observe_media_upload_rsc_props: Set resource properties from the medium properties using z_datetime:to_datetime.
  • observe_media_viewer: Return the media viewer for the audio using z_template:render.

Edit on GitHub

Observes

Notifications

observe_media_upload_props/3

Notification that a medium file has been uploaded. This is the moment to change properties, modify the file etc. The folded accumulator is the map with updated…

Notifications

observe_media_viewer/2

Request to generate a HTML media viewer for a resource. The HTML data can not contain any Javascript, as it might be serialized. This could happen if the…

Notifications

observe_media_upload_rsc_props/3

Notification that a medium file has been uploaded. This is the moment to change resource properties, modify the file etc. The folded accumulator is the map…

See also

Modules

mod_video

Adds support for viewing and handling video medium items.

Modules

mod_video_embed

This module, if activated, checks the pasted URLs in the create media / page dialog of the admin. It will show an embed option for Youtube and Vimeo URLs. It…

Tags

media

Show embed, video or audio media.

Modules

mod_oembed

Makes media resources from embeddable URLs through the OEmbed protocol.