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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@solarpunkltd/swarm-stream-js

v0.0.1

Published

JS library for streaming on Swarm

Downloads

7

Readme

A streaming library for Swarm that enables media streaming and playback (watching/listening) over Swarm.

Watch

To play a stream, first initialize a player Bee node. This node handles all requests related to playing the stream. Then, you can use the attach to initalize the player.

import { playerBee, VideoPlayer } from 'swarm-stream-react-js';

playerBee.setBee('http://localhost:1633');
const controls = attach({ media: videoRef, address: owner, topic });

// on the controls you use the followings
return {
  play,
  seek,
  restart,
  setVolumeControl,
  pause,
  continueStream,
  getDuration: getApproxDuration,
  on: emitter.on,
  off: emitter.off,
};

You can listen on events like this
controls.on(EVENTS.LOADING_PLAYING_CHANGE, (isLoading: boolean) => console.log(isLoading));

export const EVENTS = {
  LOADING_PLAYING_CHANGE: 'loadingPlaying',
  LOADING_DURATION_CHANGE: 'loadingPlaying',
  IS_PLAYING_CHANGE: 'isPlaying',
};

Stream

To stream media, initialize a streamer Bee node. This node manages requests related to streaming.

import { isStreamOngoing, startStream, stopStream, streamBee } from 'swarm-stream-js';

streamBee.setBee('http://localhost:1633');

async function startStream(
  signer: Signer, // To continuously write to Swarm feeds, a Signer (public and private key pair) must be provided.
  topic: string, // A unique topic name. This is required for playing the stream via the VideoPlayer.
  stamp: BatchId, // A valid BatchId for writing to Swarm.
  options: Options // Configuration for the stream.
): Promise<void>;

interface Options {
  video: boolean; // Whether to include video in the stream
  audio: boolean; // Whether to include audio in the stream
  timeslice: number; // The interval at which to create media segments (currently fixed at 2000ms)
  videoBitsPerSecond: number; // Defines the video quality of the stream
}

function stopStream(): void;
function isStreamOngoing(): boolean;

Limitations

Currently, the following browser features are required:

  • 'video/webm; codecs=vp9,opus' (the library is specific to WebM format)
  • Navigator.mediaDevices: MediaDevices API
  • MediaRecorder: Media recording API
  • MediaSource: Media source extensions
  • SourceBuffer: Used for appending media segments

Tests have primarily been conducted using Chrome.

How it works?

Streamer Side

A new Swarm feed is created. Each media segment from MediaRecorder is uploaded to the Swarm feed under a specific feed index. The indexing is manual to avoid lookups. Feed index 0 contains the stream's metadata, which is necessary to initialize the MediaSource.

Player Side

The player first retrieves metadata from feed index 0. It then waits for a cluster start (keyframe), ensuring that the cluster is clean. The player starts appending subsequent segments in order once the cluster is established.

Helpful docs:

  • https://docs.ethswarm.org/docs/develop/tools-and-features/feeds#what-are-feeds
  • https://www.webmproject.org/
  • https://en.wikipedia.org/wiki/Extensible_Binary_Meta_Language

An example demo project to demonstrate a simple use case: https://github.com/Solar-Punk-Ltd/swarm-stream-react-example