We use cookies (just for analytics) on this website. If you continue we will assume you are happy with it. ok

BeBanjo

Back to index

Audio track

The audio track resource represents an audio track within a rendition. For instance, a specific rendition could have multiple audio tracks (original version, dubbed version and original version in dolby digital). It is assumed that audio tracks are contained within a rendition and are not separate audio files, although this could change in the future.

This is how an audio track looks like through the API:

<?xml version='1.0' encoding='utf-8' ?>
 <audio-track>
   <id type="integer">16</id>
   <language>eng</language>
   <original-version type="boolean">true</original-version>
   <encoding>WMA9</encoding>
   <mix-type>Dolby Digital</mix-type>
   <channels>5.1</channels>
   <audio-description type="boolean">true</audio-description>
   <link href="http://movida.bebanjo.net/api/audio_tracks/16" rel="self"/>
 </audio-track>

Valid attributes

  • language (required, validated). List of possible languages as per ISO ISO 639-2/T codes by name. See http://en.wikipedia.org/wiki/List_of_ISO_639-2_codes.

  • original-version (optional). By default false. Defines if an audio track is the original version one.

  • encoding (optional). The encoding of the audio track. Any value is allowed.

  • mix-type (optional). Defines the mix type. Any value is allowed.

  • channels (optional). Defines the number of channels. Any value is allowed.

  • audio-description (optional). Defines if the audio track contains a narrative track with audio description for the visually impaired. The following values are allowed: nil, “true” and “false”.

Get a list for all audio tracks for a rendition

Audio tracks are accessed via the Rendition they belong to, as in the example below, through the link identified by the rel=”audio_tracks” attribute. Refer to the [[Movida Resource: Rendition]] page to find out how to access a Rendition.

<?xml version='1.0' encoding='utf-8' ?>
<rendition>
 <!-- ... -->
 <link rel="audio_tracks" href="http://movida.bebanjo.net/api/renditions/39/audio_tracks"/>
 <!-- ... -->
</rendition>

If we follow that link, we can fetch the list of all audio tracks for that rendition.

$ curl --digest -u robot_user:password https://movida.bebanjo.net/api/renditions/39/audio_tracks
<?xml version="1.0" encoding="UTF-8"?>
<audio-tracks type="array">
  <audio-track>
    <id type="integer">16</id>
    <language>eng</language>
    <original-version type="boolean">true</original-version>
    <encoding>WMA9</encoding>
    <mix-type>Dolby Digital</mix-type>
    <channels>5.1</channels>
    <audio-description nil="true"/>
    <link href="http://www.example.com/api/audio_tracks/16" rel="self"/>
  </audio-track>
  <audio-track>
    <id type="integer">17</id>
    <language>eng</language>
    <original-version type="boolean">true</original-version>
    <encoding>WMA9</encoding>
    <mix-type>Dolby Digital</mix-type>
    <channels>5.1</channels>
    <audio-description nil="true"/>
    <link href="http://www.example.com/api/audio_tracks/17" rel="self"/>
  </audio-track>
</audio-tracks>

Get a specific audio track

This how you recover information about a specific audio track.

$ curl --digest -u robot_user:password https://movida.bebanjo.net/api/audio_tracks/17
<?xml version="1.0" encoding="UTF-8"?>
<audio-track>
  <id type="integer">17</id>
  <language>eng</language>
  <original-version type="boolean">true</original-version>
  <encoding>WMA9</encoding>
  <mix-type>Dolby Digital</mix-type>
  <channels>5.1</channels>
  <audio-description nil="true"/>
  <link href="http://www.example.com/api/audio_tracks/17" rel="self"/>
</audio-track>

Creating audio tracks for a rendition

To create an audio track, you just need to POST a proper XML audio track representation (similar to the ones you get when fetching an audio track) to the proper URL. As explained above, that URL is in the link node whose ‘rel’ attribute equals ‘audio_tracks’.

For example, this POST would create an audio track (we’ll use curl’s @ option, which reads data to be posted from a file):

cat audio_track.xml
<audio-track>
  <language>eng</language>
  <original-version type="boolean">true</original-version>
  <encoding>WMA9</encoding>
  <mix-type>Dolby Digital</mix-type>
  <channels>5.1</channels>
  <audio-description nil="true"/>
</audio-track>
$ curl --digest -u robot_user:password -H "Content-Type: application/xml" -X POST -d @audio_track.xml "https://movida.bebanjo.net/api/renditions/39/audio_tracks"

Movida will return the full XML of the audio track just created:

<?xml version="1.0" encoding="UTF-8"?>
<audio-track>
  <id type="integer">17</id>
  <language>eng</language>
  <original-version type="boolean">true</original-version>
  <encoding>WMA9</encoding>
  <mix-type>Dolby Digital</mix-type>
  <channels>5.1</channels>
  <audio-description nil="true"/>
  <link href="http://www.example.com/api/audio_tracks/17" rel="self"/>
</audio-track>

Updating an audio track

As our introduction to REST APIs guide suggests, you can update an audio track issuing a PUT request to a given audio track URI:

cat audio_track_update.xml
<audio-track>
  <language>spa</language>
  <original-version>false</original-version>
  <channels>Stereo</channels>
</audio-track>
$ curl --digest -u robot_user:password -H "Content-Type: application/xml" -X PUT -d @audio_track_update.xml "https://movida.bebanjo.net/api/audio_tracks/17"

As always Movida will return the full XML of the audio track just updated:

<?xml version="1.0" encoding="UTF-8"?>
<audio-track>
  <id type="integer">17</id>
  <language>spa</language>
  <original-version type="boolean">false</original-version>
  <encoding>WMA9</encoding>
  <mix-type>Dolby Digital</mix-type>
  <channels>Stereo</channels>
  <audio-description nil="true"/>
  <link href="http://www.example.com/api/audio_tracks/17" rel="self"/>
</audio-track>

Deleting an audio track

You can also delete an audio track using DELETE request to each audio track URI:

$ curl --digest -u robot_user:password -X DELETE "https://movida.bebanjo.net/api/audio_tracks/17"

The DELETE request doesn’t return anything, as that audio track is now gone.

Note: Deleting an audio track won’t have any side-effect on the parent rendition.

Last updated March 24th, 2017.