Skip to main content

MkDocs plugin for wavesurfer.js

Project description

mkdocs-wavesurfer

This is a plugin for mkdocs that adds a waveform display for <audio> elements using wavesurfer.js.

This plugin only works when mkdocs-audiotag is also installed and enabled.

Quick start

Install the plugin

pip install mkdocs-wavesurfer

Enable the plugin in mkdocs.yml

plugins:
  - mkdocs-audiotag # required
  - mkdocs-wavesurfer

Embed an audio file in markdown source

As described on the mkdocs-audiotag readme.

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

The waveform will be shown below the audio element's controls.

Configuration

You can tweak how wavesurfer.js displays the waveform using a range of configuration options. See the wavesurfer.js documentation and the very nice visual examples for a full description.

Add your options under the mkdocs-wavesurfer plugin in your mkdocs.yml.

plugins:
  - mkdocs-audiotag
  - mkdocs-wavesurfer:
      height: 200
      wave_color: "#0fcb2bff"
      progress_color: rgb(0, 100, 0)
      cursor_color: red
      cursor_width: 10
      bar_width: 5
      bar_gap: 2

Waveform canvas generated with the configuration shown above

Note:

  • Defaults: You only need to specify the options you want to override, as others will use default values.
  • Colors: Can be specified as in CSS using hex values, rgb(), or color names, as shown in the example above.
  • Case: We use snake case in mkdocs.yml for consistency, as opposed to the wavesurfer.js docs which use javascript and camel case.

Use with mkdocs-material

The plugin can adapt to the color set by mkdocs-material for a visually coherent style.

plugins:
  - mkdocs-audiotag
  - mkdocs-wavesurfer:
      use_mkdocs-material_color: true

When this is enabled, the options wave_color and progress_color are overwritten, and the plugin will log a warning if they are present in mkdocs.yml.

Autopopulated options

Please note that the following wavesurfer options are populated automatically by the plugin and cannot be specified in the config:

  • media_controls
  • media
  • url
  • container

If you would like to remove the browser's default media controls, you can do so by configuring mkdocs-audiotag:

plugins:
  - mkdocs-audiotag:
      controls: false
  - mkdocs-wavesurfer

Default config values

Below are the default configuration values:

plugins:
  - mkdocs-wavesurfer:
      height: 128
      width: "100%"
      split_channels: false
      normalize: false
      wave_color: "#ff4e00"
      progress_color: "#dd5e98"
      cursor_color: "#ddd5e9"
      cursor_width: 2
      bar_width: null
      bar_gap: null
      bar_radius: null
      bar_height: null
      bar_align: ""
      min_px_per_sec: 1
      fill_parent: true
      autoplay: false
      interact: true
      drag_to_seek: false
      hide_scrollbar: false
      audio_rate: 1.0
      auto_scroll: true
      auto_center: true
      sample_rate: 8000
      use_mkdocs_material_color: false

License

This plugin is licensed under the MIT license.

Beware that wavesurfer.js is licensed under the BSD-3-Clause license.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mkdocs_wavesurfer-0.1.0.tar.gz (5.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mkdocs_wavesurfer-0.1.0-py3-none-any.whl (6.4 kB view details)

Uploaded Python 3

File details

Details for the file mkdocs_wavesurfer-0.1.0.tar.gz.

File metadata

  • Download URL: mkdocs_wavesurfer-0.1.0.tar.gz
  • Upload date:
  • Size: 5.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for mkdocs_wavesurfer-0.1.0.tar.gz
Algorithm Hash digest
SHA256 48f3ca73ddb37a225735f61984cafbcf5d7c1adf5e529e46505e11a14cff5618
MD5 160682346b4df7de279b7f02712f445c
BLAKE2b-256 506d373550fe539db00cf7d684fa9e99f4e9242e3062e9d55c688e75dcece7f6

See more details on using hashes here.

File details

Details for the file mkdocs_wavesurfer-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for mkdocs_wavesurfer-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8e2bf6c1408555f341f94744989a0a4e455a48d2369f3b030e07fd3762839154
MD5 a5b153fff21c38561a9debe5abbe19a3
BLAKE2b-256 c91f8b54db7ca374e7f3f94875b1161a740651ee6697ae74c2a7da3db4546195

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page