Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@daviddarnes/is-playing

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@daviddarnes/is-playing

A Web Component to indicate when an audio, or video, element is playing

  • 2.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
Maintainers
1
Weekly downloads
 
Created
Source

is-playing

A Web Component to indicate when an audio, or video, element is playing.

Demo | Futher reading

Examples

<script type="module" src="is-playing.js"></script>

<is-playing>
  <audio controls src="https://darn.es/sounds/daviddarnes.m4a"></audio>
</is-playing>

Features

This Web Component allows you to:

  • Select and style elements depending if an audio or video element is playing, using :state(playing) state selector
  • Polyfill for the :playing CSS selector
  • Surface and utilise the ID of the audio or video element playing with a playing attribute value on the is-playing element

Installation

You have a few options (choose one of these):

  1. Install via npm: npm install @daviddarnes/is-playing
  2. Download the source manually from GitHub into your project.
  3. Skip this step and use the script directly via a 3rd party CDN (not recommended for production use)

Usage

Make sure you include the <script> in your project (choose one of these):

<!-- Host yourself -->
<script type="module" src="is-playing.js"></script>
<!-- 3rd party CDN, not recommended for production use -->
<script
  type="module"
  src="https://www.unpkg.com/@daviddarnes/is-playing@2.0.0/is-playing.js"
></script>
<!-- 3rd party CDN, not recommended for production use -->
<script
  type="module"
  src="https://esm.sh/@daviddarnes/is-playing@2.0.0"
></script>

Multiple audio and video elements

is-playing will also reveal which audio element is playing by adding a playing attribute to itself with the value of the playing elements ID. Note that in order for this to happen the playing element must have an id and there needs to be at least 2 audio or video elements:

<is-playing>
  <audio
    id="audio-2"
    controls
    src="https://darn.es/sounds/daviddarnes2.m4a"
  ></audio>
  <audio
    id="audio-3"
    controls
    src="https://darn.es/sounds/daviddarnes3.m4a"
  ></audio>
</is-playing>

Credit

With thanks to the following people:

Keywords

FAQs

Package last updated on 18 Sep 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc