npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ncplayer

v0.0.8

Published

A video player with support for preview on track hover.

Downloads

6

Readme

ncplayer

Usage

import { NCPlayer, sig } from "ncplayer";

const source = sig("./video.mp4");
const previewSource = sig("./preview.mp4");
const poster = sig("./poster.jpg");

// each prop can be either a raw value or a signal
const player = NCPlayer({
  source: source,
  preview: previewSource,
  poster: poster,
  preload: "metadata",
  width: 640,
  height: 360,
});

document.body.appendChild(player);

function changeSource() {
  source.dispatch("./video2.mp4");
  previewSource.dispatch("./preview2.mp4");
  poster.dispatch("./poster2.jpg");
}

UI Elements size

The size of all UI elements of the NCPlayer can be controlled by setting the CSS font-size of the root element (.ncplayer). Font size however does not affect the width or height of the player itself. To control the dimensions of the player doing so via either the width and height props or CSS rules on the inner <video> tag is recommended (ex. .ncplayer video.main-player { width: 16em; }.)

Properties

All properties, except for dismounter, can be provided to the NCPlayer as either a value of the supported type, or a signal containing a value of that same type. (ex. width can be either a number or a Signal<number>)

| Property Name | Type | Description | Default Value | | --------------------- | ---------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------- | | source | string | URL(s) of the video to play. If provided multiple sources, the player will allow the user to select the source. | undefined | | preview | string | URL of the video to use as the preview. Preview will be displayed above the progress bar as the user hovers over it. | undefined | | subtitles | Array<SubtitleTrack> | Array of subtitle tracks to allow user to select. See SubtitleTrack definition here. | [] | | width | number | Width of the player when not in the fullscreen mode. | undefined | | height | number | Height of the player when not in the fullscreen mode. | undefined | | previewWidth | number | Width of the preview video. | 320 | | previewHeight | number | Height of the preview video. | undefined | | previewUpdateThrottle | number | Determines how often the preview video timestamp should be updated as the user hovers over the progress bar. | 250 (ms) | | controlsTimeout | number | Time in milliseconds after which the controls should be hidden. | 1000 (ms) | | swipeControlRange | number | Maximum time range (in ms) it's possible to seek forward or backward by swiping on a mobile device. | 60_000 (ms) | | persistentVolume | boolean | Whether the player volume should persist between reloads. | false | | autoplay | boolean | Whether the video should start playing as soon as it is ready. (same as the native <video> property) | false | | muted | boolean | Whether the video should be muted. (same as the native <video> property) | false | | poster | string | URL of the image to use as the poster. (same as the native <video> property) | undefined | | preload | string | Whether the video should be preloaded. Possible values are none, metadata and auto. (same as the native <video> property) | undefined | | loop | boolean | Whether the video should loop. (same as the native <video> property) | false | | styles | false \| string | When set to false, no styles will be added to the DOM, resulting in the unstyled player. (you will need to add styles yourself). When given a string, that string will be inserted into the DOM as a style tag instead of the default styles. | undefined | | keySeekDuration | number | The duration in seconds that the player should seek when the user presses the left or right arrow keys. | 5 | | globalKeyListener | boolean | By default player will listen to all key events that don't have an interactable target. If set to false only events with a target within the player will be listened to. | true | | dismounter | Dismounter | An interface that should expose a ondismount method that registers a listener. NCPlayer will register teardown callbacks to this interface. See Dismounter definition here. | undefined |

SubtitleTrack

type SubtitleTrack = {
  id: string;
  src: string;
  srclang: string;
  label: string;
  default?: boolean;
};

Dismounter

type Dismounter = {
  ondismount(fn: Function): void;
};