@100mslive/hls-stats 0.0.3-alpha.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +60 -0
- package/package.json +2 -2
package/README.md
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# @100mslive/hms-stats
|
|
2
|
+
|
|
3
|
+
A simple library for HLS stats for Hls.js.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```shell
|
|
8
|
+
yarn add @100mslive/hls-stats
|
|
9
|
+
```
|
|
10
|
+
or
|
|
11
|
+
|
|
12
|
+
```shell
|
|
13
|
+
npm install --save @100mslive/hls-stats
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Usage
|
|
17
|
+
|
|
18
|
+
### initialization
|
|
19
|
+
```javascript
|
|
20
|
+
|
|
21
|
+
import Hls from "hls.js";
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Initialize Hls.js and attach the video element.
|
|
25
|
+
*/
|
|
26
|
+
const hlsInstance = new Hls();
|
|
27
|
+
hlsInstance.loadSource(hlsUrl);
|
|
28
|
+
hlsInstance.attachMedia(videoEl);
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* initialize HlsStats
|
|
32
|
+
*/
|
|
33
|
+
const hlsStats = new HlsStats(hlsController.getHlsJsInstance(), videoEl);
|
|
34
|
+
|
|
35
|
+
```
|
|
36
|
+
### Subscribing to Stats
|
|
37
|
+
`hlsStats` have a `subscribe` function which takes two parameter. a `callbackFn` and an `interval` in ms.
|
|
38
|
+
The `interval` tells how frequent you want hls-stats to report back to you. Default is 2000ms
|
|
39
|
+
|
|
40
|
+
```javascript
|
|
41
|
+
const unsubscribe = hlsStats.subscribe(state => {
|
|
42
|
+
// ...
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
```
|
|
46
|
+
the `subscribe()` also returns a reference to `unsubscribe()` function which could later be used to unsubscribe
|
|
47
|
+
from your subscription
|
|
48
|
+
|
|
49
|
+
## Exposed Stats
|
|
50
|
+
hls-stats currently exposes the following stats
|
|
51
|
+
|
|
52
|
+
| Name | Description | Unit | Usage |
|
|
53
|
+
|----------------------------------|---------------------------------------------------------|-----------------|-----------------------------------------------------------------------------------------------|
|
|
54
|
+
| bandwidthEstimate | The current bandwidth, as seen by the player | bits per second | Use this to show the current network speed of the user |
|
|
55
|
+
| bitrate | server indicated bitrate of current layer of hls stream | bits per second | Use to know the bitrate required for current layer |
|
|
56
|
+
| bufferedDuration | buffered duration from the current position | ms | This can be used to show how much data is buffered from the current location (forward buffer) |
|
|
57
|
+
| distanceFromLiveEdge | The distance from the live edge | ms | Used to know currently buffered duration ahead |
|
|
58
|
+
| droppedFrames | The number of dropped frames till now | | Used to calculate the total num of dropped frames |
|
|
59
|
+
| videoSize.width videoSize.height | The width and height of the video | px | Used to know the resolution being played |
|
|
60
|
+
| watchDuration | Total duration watched | ms | used to know the overall watch duration (not the stream length) |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@100mslive/hls-stats",
|
|
3
|
-
"version": "0.0.3
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"description": "A simple library that provides stats for your hls stream",
|
|
5
5
|
"main": "dist/index.cjs.js",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -36,5 +36,5 @@
|
|
|
36
36
|
"peerDependencies": {
|
|
37
37
|
"hls.js": "^1.2.5"
|
|
38
38
|
},
|
|
39
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "8f89cfd2a2898848be5368da6211519f6c2c1cef"
|
|
40
40
|
}
|