Skip to main content

mkdocs-audiotag

This is a plugin for the wonderful mkdocs static site generator that allows for easy embedding of audio files using the default HTML5 audio element.

This plugin was made as an alternative to mkdocs-audio, in order to support embedding multiple audio file sources. This is sometimes necessary because file formats and container types are not supported equally well in different browsers or on different platforms.

Quick start

Install the plugin

pip install mkdocs-audiotag

Enable the plugin in mkdocs.yml

plugins:
  - mkdocs-audiotag

Embed an audio file

![audio/ogg](my-audio-file.ogg)

Note: audio/ogg is the MIME type for the embedded file.

Configuration

You can customize the behavior and appearance of the audio element by specifying options under the plugin in your mkdocs.yml. The defaults are sane, so in most cases this isn't necessary.

# Default options
plugins:
  - mkdocs-audiotag:
      autoplay: false
      controls: true
      loop: false
      muted: false
      preload: 'metadata'
      width: 100%

Options

  • autoplay: If true, audio will start playing automatically when the page loads. MDN: autoplay

  • controls: If true, playback controls (play, pause, etc.) are shown. MDN: controls

  • loop: If true, audio will restart automatically after finishing. MDN: loop

  • muted: If true, audio will be muted on page load. MDN: muted

  • preload: Controls what gets downloaded on page load:

    • 'none': Don’t preload audio
    • 'metadata': Preload only metadata (default)
    • 'auto': Preload the whole file MDN: preload
  • width:
    Sets the CSS width of the audio player (e.g., '100%', '300px').
    MDN: style

Config examples

Use the default config options

plugins:
  - mkdocs-audiotag

Set audio playback to loop, don't preload anything

plugins:
  - mkdocs-audiotag:
      loop: true
      preload: none

Set the width of the audio player to 300 pixels

plugins:
  - mkdocs-audiotag:
      width: 300px

How to write the markdown content

There is no standard way to describe audio media in markdown. Inspired by mkdocs-audio, we use the same syntax as with images. Instead of a title or a static marker, we specify the file's MIME type, which must begin with audio/ (otherwise, the plugin will not recognise the tag).

![audio/ogg](my-audio-file.ogg)

To specify multiple source files, just include another file immediately below the first line, i.e. with no extra line breaks. The browser will try to load the first audio file. If that fails, it will move on to the next one, and so forth. This means you can put the preferred format first, and then add fallback options below. See notes on this browser behavior at MDN.

![audio/ogg](my-audio-file.ogg)
![audio/mpeg](my-audio-file.mp3)

If you need to caption the audio element, use a separate plugin for that.

MIME types

Some MIME types for common audio file formats are:

  • AAC/M4A: audio/mp4
  • MP3: audio/mpeg
  • OGG: audio/ogg
  • FLAC: audio/flac
  • WAVE: audio/wav
  • AIFF: audio/aiff

Metadata

Release files for mkdocs-audiotag 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mkdocs-audiotag 0.1.1
File Size Uploaded Provenance
mkdocs_audiotag-0.1.1.tar.gz 4.6 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for mkdocs-audiotag 0.1.1
File Interpreter ABI Platform
mkdocs_audiotag-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 9.7 kB

Release files / mkdocs_audiotag-0.1.1.tar.gz

Download URL mkdocs_audiotag-0.1.1.tar.gz
Size 4.6 kB
Tags Source
SHA-256 checksum
How to use checksums
4de89c598bb18932bd976a98a2009432dc4f3993fcd177dd7594401ae7e90941
BLAKE2b-256 checksum
How to use checksums
7762de6b780fcdd46cb0c409637b8ac09bd21081836454e1e12ef73b57dba5ff
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.3

Release files / mkdocs_audiotag-0.1.1-py3-none-any.whl

Download URL mkdocs_audiotag-0.1.1-py3-none-any.whl
Size 5.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0b3fca854e19b8f7e1d30bfc636246f4564ee7611e07e880a478f0f3d1a9d3e3
BLAKE2b-256 checksum
How to use checksums
f98dc8d2ebb96ca274f55913d22d6313883c0b763f52b1439193f7e49817422b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.3

Security for mkdocs-audiotag 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page