Skip to content

Mux Element Properties

This documentation covers all available element properties. View MUX documentation asset properties.

Complete Variable Reference

Query-Only Variables (for filtering assets)

These variables can only be used in queries to filter MuxAsset elements, not accessed as properties on individual assets.

Basic Asset Properties

Upload and Processing Properties

Playback and Rendition Properties

Quality and Resolution Properties

Custom Data Properties

Track Properties (Query-Only)

Metadata Properties (Query-Only)

Folder and Volume Properties

Standard Element Query Methods

  • id - Filter by element ID
  • offset - Offset results
  • limit - Limit number of results
  • orderBy - Order results

Example Usage:

twig
{# Access basic properties #}
{{ asset.assetId }}
{{ asset.duration }}
{{ asset.aspectRatio }}
{{ asset.isLive }}

{# Access track information #}
{% for track in asset.tracks %}
    {{ track.type }} - {{ track.name }}
{% endfor %}

{# Access playback id #}
{{ asset.playback_ids[0].id }}

{# Access metadata #}
{{ asset.meta.title }}
{{ asset.meta.creatorId }}

{# Check if asset is ready #}
{% if asset.assetStatus == 'ready' %}
    {# Asset is ready for playback #}
{% endif %}

Static Renditions

twig
{% set muxAsset = craft.mux.one() %}

{# For usecured assets #}
{% if muxAsset.static_renditions|length %}
    <a href="https://stream.mux.com/{{ muxAsset.playback_ids[0].id }}/{{ muxAsset.static_renditions.files[0].name }}?download={{ muxAsset.title }} download target="_blank">Download Video/Audio</a>
{% endif %}

{# For secured playback assets #}
{% if muxAsset.securePlayback %}
    {% set videoToken = muxAsset.getSecurePlaybackJWT(keyID, 'v') %}
    {% if muxAsset.static_renditions|length %}
        <a href="https://stream.mux.com/{{ muxAsset.playback_ids[0].id }}/{{ muxAsset.static_renditions.files[0].name }}?download={{ muxAsset.title }}&token={{ videoToken }}" download target="_blank">Download Video/Audio</a>
    {% endif %}
{% endif %}

Methods

getPlaybackId string

twig
{# Returns the first playback_id in the playback_ids property array #}
{% set muxAsset = craft.mux.one() %}
{% set playbackId = muxAsset.getPlaybackId() %}

securePlayback boolean

twig
{% set muxAsset = craft.mux.one() %}
{% if muxAsset.securePlayback %}{% endif %}

signedKeys array

twig
{% set muxAsset = craft.mux.one() %}
{% set signedKeys = muxAsset.signedKey %}

getSecurePlaybackJWT(signedKey, mediaType, options) string

  • signedKey: Mux Signed Key
  • mediaType: v = video, t = thumbnail, g = gif, s = storyboard
  • options: ["time" => 10, "width" => 640, "fit_mode" => "smartcrop"]
twig
{% set muxAsset = craft.mux.one() %}
{% set signedKeys = muxAsset.getSecurePlaybackJWT(signedKey, mediaType, options) %}