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

@100mslive/hls-stats

Package Overview
Dependencies
Maintainers
0
Versions
419
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@100mslive/hls-stats

A simple library that provides stats for your hls stream

  • 0.4.28
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2.8K
increased by13.99%
Maintainers
0
Weekly downloads
 
Created
Source

@100mslive/hms-stats

Lint, Test and Build Bundle Size License Tree shaking

A simple library for HLS stats for Hls.js.

Installation

yarn add @100mslive/hls-stats

or

npm install --save @100mslive/hls-stats

Usage

initialization


import Hls from "hls.js";

/**
 * Initialize Hls.js and attach the video element.
 */
const hlsInstance = new Hls();
hlsInstance.loadSource(hlsUrl);
hlsInstance.attachMedia(videoEl);

/**
 * initialize HlsStats
 */
const hlsStats = new HlsStats(hlsController.getHlsJsInstance(), videoEl);

Subscribing to Stats

hlsStats have a subscribe function which takes two parameter. a callbackFn and an interval in ms. The interval tells how frequent you want hls-stats to report back to you. Default is 2000ms

const unsubscribe = hlsStats.subscribe(state => {
    // ...
});

the subscribe() also returns a reference to unsubscribe() function which could later be used to unsubscribe from your subscription

Exposed Stats

hls-stats currently exposes the following stats

NameDescriptionUnitUsage
bandwidthEstimateThe current bandwidth, as seen by the playerbits per secondUse this to show the current network speed of the user
bitrateserver indicated bitrate of current layer of hls streambits per secondUse to know the bitrate required for current layer
bufferedDurationbuffered duration from the current positionmsThis can be used to show how much data is buffered from the current location (forward buffer)
distanceFromLiveEdgeThe distance from the live edgemsUsed to know currently buffered duration ahead
droppedFramesThe number of dropped frames till nowUsed to calculate the total num of dropped frames
videoSize.width videoSize.heightThe width and height of the videopxUsed to know the resolution being played
watchDurationTotal duration watchedmsused to know the overall watch duration (not the stream length)

FAQs

Package last updated on 10 Jan 2025

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