audio Object

Audio file block for use within content template displays.

Attributes

Attribute Required Description
Base file attributes
title Yes string Title of file.
description No number Description of file.
url Yes string URL where original file is stored/downloadable.
extension Yes string Extension of file. For example, mp3.
url_slug Yes string File name minus extension.
content_type Yes string MIME type of file. For example, audio/mp3.
file_size Yes number Size of file in bytes.
keywords No string List of keywords to describe file.
downloadable? Yes boolean Whether or not the content author specified to include a download link to this file.
published_at No date Timestamp of when file was first published.
created_at Yes date Timestamp of when file was created.
updated_at Yes date Timestamp of when file was last updated.
id Yes number ID of file.
audio block-specific attributes
embeddable? Yes boolean Whether or not the content author specified to embed this audio directly onto the page through an audio player.
embed_urls Yes array Collection of web-friendly embed_urls, particularly useful for building a group of <source> tags within the HTML5 <audio> tag.
duration_in_ms Yes number Duration of audio in milliseconds.
audio_codec Yes string Codec used to encode audio.
audio_sample_rate Yes string Audio sample rate.
audio_channels Yes number Number of channels of audio.
audio_bitrate Yes number Bitrate of audio in kilobytes per second.

Category

Block Objects

Description

The audio block object defines the blueprint for content blocks based on the base Audio content template.

Within your content templates’ displays, you would reference the block’s display_var_name containing the audio data. (It won’t necessarily be named audio but rather what you defined in the content-templates.json file.)

Here is an example display template using an audio content block with a display_var_name of interview:

      {% comment %}
        HTML5 <audio> tag with web-friendly embed URLs.
      {% endcomment %}
      {% if interview.embeddable? %}
        <div class="audio-player">
          <audio preload>
            {% for embed_url in interview.embed_urls %}
              <source
                type="{{ embed_url.content_type }}"
                src="{{ embed_url.url }}"
              >
            {% endfor %}
          </audio>
        </div>
      {% endif %}
      
      {% comment %}
        Link to download mp3 version of audio file.
        Example output: "Download: Interview with the Vampire (mp3)"
      {% endcomment %}
      {% if interview.downloadable? %}
        <p class="file-download">
          Download:
          {% for embed_url in interview.embed_urls %}
            {% if embed_url.extension == 'mp3' %}
              <a href="{{ embed_url.url }}">
                {{ interview.title }} ({{ embed_url.extension }})
              </a>
              {% break %}
            {% endif %}
          {% endfor %}
        </p>
      {% endif %}