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 🙏

© 2026 – Pkg Stats / Ryan Hefner

imaginary-player

v0.0.3

Published

pseudo-streaming/broadcasting media player

Readme

imaginary-player

npm module for pseudo-streaming/broadcasting

Build Status

Motivation

Broadcasting is a complex problem (such that every visitor would be sychronized to watch the same moment). Luckly with HTML5 <video> and Media Fragments URI, the client can do most of this work -- we just need to supply where something is currently playing. :sunglasses: Hence this module is a fancy timer in essence. See below for HTML <video> support.

Usage examples

First things first. Install the package.

npm install imaginary-player [--save]

You will need to initialize the playlist like below. Each playlist item can be your arbitrary data but it must respond to the duration property.

var player = require('imaginary-player');

player.playlist([
  { duration: '31:29', title: 'All Arsenal Goals 2012/13',                        location: '1.webm' },
  { duration: '15:00', title: 'The Greatest Ever Arsenal Player - Thierry Henry', location: '2.webm' },
  { duration: '8:17',  title: 'Kieran Gibbs - Still Breathing (2012/13)',         location: '3.webm' }
]).play();

Alternatively, you can defer calling play() until later. play() will start playing from the beginning of the playlist and loop.

player.play();

You can also specify which index it should start playing from. play() is equivalent to play(0).

player.play(1);

Specify which attribute should show up in the logs:

player.logAttribute('title');
// 1371408021917 now playing: All Arsenal Goals 2012/13

Instead of playing in the order of the original playlist, the player can shuffle at the beginning of each playthrough. This is nice for when your media playlist becomes much too predictable.

player.shuffle(true);
// at the beginning, shuffling...
// 1371408021917 now playing: The Greatest Ever Arsenal Player - Thierry Henry

Once you have it playing, you can now() ask for what/where it's currently playing. Using the popular web application framework express, you can serve that information like below:

var express = require('express');

var app = express();

app.get('/where', function(req, res) {
  res.send( player.now() );
});

app.listen(3000);

This would produce a response like below. The played attribute represents the current playing marker in seconds.

{
  "duration": "31:29",
  "title": "All Arsenal Goals 2012/13",
  "location": "1.webm",
  "played": 589.743
}

Your client can then consume that information like so:

var screen = document.querySelector('your-<video>-element'); // with autoplay attribute maybe?

var now = res.body; // server-returned response
screen.src = now.location + "#t=" + now.played;

About HTML5 video support

I'm not a video / encoding format expert. This article from diveintohtml5 gives good insight. ####tl;dr

  • .webm (VP8 + Vorbis)
  • .mp4 (H.264 + AAC)
  • .ogg (Theora + Vorbis)

Fun facts

By coincidence :wink:, Jay-Z has an awesome track named Imaginary Player.