``
--------------------
A custom HTML element that wraps the Podlove Web Player 5. It handles lazy
loading, dark mode detection, and an optional click-to-load facade.
Template Usage
^^^^^^^^^^^^^^
The element is rendered by the shared template
``cast/audio/audio.html``:
.. code-block:: html+django
{% if podlove_load_mode == "facade" %}
{% endif %}
Data Attributes
^^^^^^^^^^^^^^^
``data-url`` (required)
The API endpoint returning the Podlove episode JSON for this audio file.
``data-config``
URL for the player configuration (theme colors, fonts). Defaults to
``/api/audios/player_config/``. You can customize the theme per template
base directory using the ``CAST_PODLOVE_PLAYER_THEMES`` setting.
``data-embed``
URL of the Podlove Web Player embed script. Defaults to the CDN version
at ``https://cdn.podlove.org/web-player/5.x/embed.js``. Django Cast ships
a local copy at ``cast/js/web-player/embed.5.js``.
``data-template``
Optional Podlove template name passed through to the player initialization.
``data-load-mode``
Controls how the player is initialized. Two values are supported:
- ``"click"`` — displays a "Load player" button; the player loads only
when clicked. Used on **list pages** to avoid loading multiple heavy
player instances at once.
- ``"facade"`` — the server renders a static preview (cover art, title,
play button) inside the element. The player auto-initializes via
``IntersectionObserver`` and is injected into the existing container.
Used on **post detail pages**.
If omitted, the player auto-initializes with a plain placeholder.
Initialization Behavior
^^^^^^^^^^^^^^^^^^^^^^^
**Auto-init** (no ``data-load-mode``, or ``data-load-mode="facade"``):
1. The element waits for the page ``load`` event.
2. A shared ``IntersectionObserver`` (with a 200 px root margin) watches the
element.
3. When the element enters the viewport, initialization is scheduled via
``requestIdleCallback``.
4. The embed script is loaded (once, shared across all players on the page),
then the Podlove player is created inside the element.
In facade mode, the server-rendered preview (cover art, title, decorative play
button and progress bar) is visible while the player loads. The JS skips
creating its own placeholder when it detects a ``.podlove-player-container``
already present inside the element. The player ``