Skip to main content

No project description provided

Project description

MkDocs Video

This plugin allows you to embed videos on the documentation pages using a simple Markdown syntax.

Contents

Installation

Install the package with pip:

$ pip install mkdocs-video

Enable the plugin in the mkdocs.yml file:

plugins:
    - mkdocs-video

See how to use MkDocs Plugins

Usage

To add a video to the final documentation page, you need to use the Markdown syntax for images with a specific name (hereinafter marker).

See how to use Markdown syntax

Example:

content folder structure

├── content
|   ├── ...
│   ├── video.md
│   └── videos
│       └── costa_rica.mp4
└── mkdocs.yml

video.md

# Video example

Lorem ipsum dolor sit amet

![type:video](https://www.youtube.com/embed/LXb3EKWsInQ)

<mkdocs-url>/video

You can also use relative paths for videos stored together with your content

![type:video](./videos/costa_rica.mp4)

Configuration

The following parameters can be used to change the functionality and appearance of video elements in the final HTML. Keep in mind that the plugin configuration parameters are applied globally to all relevant marked elements. To fine-tune each video element, you can use the Attribute Lists extension.

When using this plugin and the mentioned extension together, the following rules apply (with an illustrative examples):

  1. [Let's assume we have this plugin configuration]

    # mkdocs.yml
    markdown_extensions:
      - attr_list
    plugins:
      - mkdocs-video:
          is_video: True
          video_muted: True
          video_controls: True
          css_style:
            width: "50%"
    
  2. The plugin attributes are used globally by default

    ![type:video](video.mp4)
    
    <video style="width:50%" muted="" controls="" alt="type:video">
       <source src="video.mp4" type="video/mp4">
    </video>
    
  3. The extension attributes will override the corresponding plugin attributes, but the rest will remain by default.

    ![type:video](video.mp4){: style='width: 100%'}
    
    <video style="width: 100%" muted="" controls="" alt="type:video">
       <source src="video.mp4" type="video/mp4">
    </video>
    
  4. The plugin attributes can be disabled for specific video element by adding disable-global-config attribute.

    ![type:video](video.mp4){: disable-global-config style='width: 100%'}
    
    <video alt="type:video" style="width: 100%">
       <source src="video.mp4" type="video/mp4">
    </video>
    
  5. The extension attribute src will override video source... Do what you want with this info 🙃.

    ![type:video](video.mp4){: src='another-video.mp4'}
    
    <video style="width:50%" muted="" controls="" alt="type:video">
       <source src="another-video.mp4" type="video/mp4">
    </video>
    

Marker

By default, the string type:video is used as a marker in the Markdown syntax.

You can change this value by adding the following lines to your mkdocs.yml:

plugins:
  - mkdocs-video:
      mark: "custom-marker"

Now you can use this marker in the Markdown syntax:

![custom-marker](https://www.youtube.com/embed/LXb3EKWsInQ)

Style

By default, the following CSS styles are used for the <iframe> tag that is inserted into the final page:

position: relative;
width: 100%;
height: 22.172vw;

You can change the style by adding the following lines to your mkdocs.yml:

plugins:
  - mkdocs-video:
      css_style:
        width: "100%"
        height: "22.172vw"
        ...

Tag <video>

By default, the <iframe> tag will be used to display the video in the final page, but in some cases you may need to use <video> tag instead. You can use it by adding the following lines to your mkdocs.yml:

plugins:
  - mkdocs-video:
      is_video: True
      ...

Video type

This parameter will only work with the <video> tag (is_video: True)

You can specify the MIME type of the video (default: mp4) resource by adding the following lines to your mkdocs.yml:

plugins:
  - mkdocs-video:
      is_video: True
      video_type: ogg
      ...

Video autoplay

This parameter will only work with the <video> tag (is_video: True)

You can specify whether the video should be played automatically (default: False) or not by adding the following lines to your mkdocs.yml:

plugins:
  - mkdocs-video:
      is_video: True
      video_autoplay: True
      ...

The operation of this parameter may be affected by browser settings or video provider configuration

Video loop

This parameter will only work with the <video> tag (is_video: True)

You can specify whether the video should be looped (default: False) or not by adding the following lines to your mkdocs.yml:

plugins:
  - mkdocs-video:
      is_video: True
      video_loop: True
      ...

The operation of this parameter may be affected by browser settings or video provider configuration

Video muted

This parameter will only work with the <video> tag (is_video: True)

You can specify whether the video should be muted (default: False) or not by adding the following lines to your mkdocs.yml:

plugins:
  - mkdocs-video:
      is_video: True
      video_muted: True
      ...

The operation of this parameter may be affected by browser settings or video provider configuration

Video controls

This parameter will only work with the <video> tag (is_video: True)

You can specify whether the video controls should be displayed (default: True) or not by adding the following lines to your mkdocs.yml:

plugins:
  - mkdocs-video:
      is_video: True
      video_controls: False
      ...

The operation of this parameter may be affected by browser settings or video provider configuration

Embedding examples

The following list contains some of the popular services, as well as examples of direct and embedded links to their videos.

Contributing

  1. Fork it.
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request

License

The MIT License (MIT)

Copyright (c) 2023 Mikalai Lisitsa

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Did you like it?

soulless.viewer

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-video-1.5.0.tar.gz (5.6 kB view details)

Uploaded Source

Built Distribution

mkdocs_video-1.5.0-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

Details for the file mkdocs-video-1.5.0.tar.gz.

File metadata

  • Download URL: mkdocs-video-1.5.0.tar.gz
  • Upload date:
  • Size: 5.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.9

File hashes

Hashes for mkdocs-video-1.5.0.tar.gz
Algorithm Hash digest
SHA256 0defc018f4b7927f8afffc4d8e039c84dfba636dffc5e25e2bfa8d6350bc8eca
MD5 f821ca70a9f44b555da3d805a434a984
BLAKE2b-256 cf1645213649b6756744f36f31014fc8673df1d7c998bb9a801c2d769fff4114

See more details on using hashes here.

File details

Details for the file mkdocs_video-1.5.0-py3-none-any.whl.

File metadata

File hashes

Hashes for mkdocs_video-1.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b35613d4dacbac2dfa94d8c2600383cda14ad99a1fa1542b5fc4e9c6d19e9fe1
MD5 237d33804fd2777c5c620fa1bae5dbca
BLAKE2b-256 cc3ab51e305eca21cdd58f4eb06973099ba0ea679b1f437a92a49f8fc576310e

See more details on using hashes here.

Supported by

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