https://github.com/daviddarnes/duration-property
A Web Component to surface an audio or video's duration as a CSS Custom Property
https://github.com/daviddarnes/duration-property
component components customelement customelements webcomponent webcomponents
Last synced: about 1 year ago
JSON representation
A Web Component to surface an audio or video's duration as a CSS Custom Property
- Host: GitHub
- URL: https://github.com/daviddarnes/duration-property
- Owner: daviddarnes
- License: mit
- Created: 2023-12-10T23:41:50.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-11-14T12:06:47.000Z (over 1 year ago)
- Last Synced: 2025-04-12T02:05:37.132Z (about 1 year ago)
- Topics: component, components, customelement, customelements, webcomponent, webcomponents
- Language: HTML
- Homepage: https://daviddarnes.github.io/duration-property/demo.html
- Size: 15.6 KB
- Stars: 13
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# `duration-property`
A Web Component to surface an audio or video's duration as a CSS Custom Property.
**[Demo](https://daviddarnes.github.io/duration-property/demo.html)** | **[Further reading](https://darn.es/duration-property-web-component/)**
## Examples
```html
```
## Features
This Web Component allows you to:
- Surface the duration of an audio or video elements source duration as a CSS Custom Property (`--duration`)
- Update the `--duration` custom property if the duration of the source changes
## Installation
You have a few options (choose one of these):
1. Install via [npm](https://www.npmjs.com/package/@daviddarnes/duration-property): `npm install @daviddarnes/duration-property`
1. [Download the source manually from GitHub](https://github.com/daviddarnes/duration-property/releases) into your project.
1. Skip this step and use the script directly via a 3rd party CDN (not recommended for production use)
### Usage
Make sure you include the `` in your project (choose one of these):
```html
<!-- Host yourself -->
<script type="module" src="duration-property.js">
```
```html
```
```html
```
## Credit
With thanks to the following people:
- [Zach Leatherman](https://zachleat.com) for inspiring this [Web Component repo template](https://github.com/daviddarnes/component-template)