@livepeer/core
Advanced tools
Comparing version 1.1.3 to 1.1.4
@@ -8,3 +8,3 @@ export { createAsset, createStream, getAsset, getAssetMetrics, getLivepeerProvider, getPlaybackInfo, getStream, getStreamSession, getStreamSessions, updateAsset, updateStream, watchLivepeerProvider, } from './actions'; | ||
export { createControllerStore, getMediaSourceType } from './media'; | ||
export type { AudioSrc, ControlsOptions, DeviceInformation, ElementSize, HlsSrc, MediaControllerState, MediaControllerStore, MediaMetrics, MediaSizing, MetricsStatus, PlaybackMonitor, Src, VideoSrc, } from './media'; | ||
export type { AudioSrc, ControlsOptions, DeviceInformation, ElementSize, HlsSrc, MediaControllerState, MediaControllerStore, MediaMetrics, MediaSizing, MetricsStatus, PlaybackMonitor, PlayerPropsOptions, Src, VideoSrc, } from './media'; | ||
export { createStorage, noopStorage } from './storage'; | ||
@@ -11,0 +11,0 @@ export type { ClientStorage as Storage } from './storage'; |
@@ -9,2 +9,3 @@ import { StoreApi } from 'zustand/vanilla'; | ||
isAndroid: boolean; | ||
userAgent: string; | ||
}; | ||
@@ -32,2 +33,6 @@ export type MediaSizing = { | ||
isVolumeChangeSupported: boolean; | ||
/** If autoplay was passed in to Player */ | ||
autoplay: boolean; | ||
/** If priority was passed in to Player */ | ||
priority: boolean; | ||
/** If the media is current playing or paused */ | ||
@@ -102,6 +107,7 @@ playing: boolean; | ||
export type MediaControllerStore<TElement> = StoreApi<MediaControllerState<TElement>>; | ||
export declare const createControllerStore: <TElement>({ element, device, storage, opts, }: { | ||
export declare const createControllerStore: <TElement>({ element, device, storage, playerProps, opts, }: { | ||
element: TElement | null; | ||
device: DeviceInformation; | ||
storage: ClientStorage; | ||
playerProps: PlayerPropsOptions; | ||
opts: ControlsOptions; | ||
@@ -125,1 +131,6 @@ }) => Omit<StoreApi<MediaControllerState<TElement>>, "persist"> & { | ||
}; | ||
export type PlayerPropsOptions = { | ||
autoPlay?: boolean; | ||
muted?: boolean; | ||
priority?: boolean; | ||
}; |
export { createControllerStore, DEFAULT_AUTOHIDE_TIME, DEFAULT_VOLUME_LEVEL, } from './controller'; | ||
export type { ControlsOptions, DeviceInformation, ElementSize, MediaControllerState, MediaControllerStore, MediaSizing, } from './controller'; | ||
export type { ControlsOptions, DeviceInformation, ElementSize, MediaControllerState, MediaControllerStore, MediaSizing, PlayerPropsOptions, } from './controller'; | ||
export { addMediaMetricsToStore } from './metrics'; | ||
@@ -4,0 +4,0 @@ export type { MediaMetrics, MetricsStatus, PlaybackMonitor } from './metrics'; |
import { MediaControllerStore } from '../controller'; | ||
type RawMetrics = { | ||
ttff: number; | ||
firstPlayback: number; | ||
@@ -16,6 +17,8 @@ nWaiting: number; | ||
playbackScore: number | null; | ||
player: 'generic'; | ||
player: 'livepeer-js'; | ||
pageUrl: string; | ||
sourceUrl: string; | ||
duration: number | null; | ||
autoplay: boolean; | ||
userAgent: string; | ||
}; | ||
@@ -40,3 +43,13 @@ type PlaybackRecord = { | ||
} | ||
declare class Timer { | ||
totalTime: number; | ||
countStarts: number; | ||
startTime: number; | ||
start(): void; | ||
stop(): void; | ||
getTotalTime(): number; | ||
getCountStarts(): number; | ||
} | ||
export declare class MetricsStatus<TElement> { | ||
requestedPlayTime: number; | ||
retryCount: number; | ||
@@ -47,17 +60,11 @@ connected: boolean; | ||
previousMetrics: RawMetrics | null; | ||
timeWaiting: number; | ||
waitingSince: number; | ||
timeStalled: number; | ||
stalledSince: number; | ||
timeUnpaused: number; | ||
unpausedSince: number; | ||
timeWaiting: Timer; | ||
timeStalled: Timer; | ||
timeUnpaused: Timer; | ||
constructor(store: MediaControllerStore<TElement>); | ||
_getTimeWaiting(): number; | ||
_getTimeStalled(): number; | ||
_getTimeUnpaused(): number; | ||
addError(error: string): void; | ||
incrementStalled(): void; | ||
incrementWaiting(): void; | ||
getFirstPlayback(): number; | ||
setFirstPlayback(): void; | ||
getTtff(): number; | ||
setTtff(): void; | ||
setPlaybackScore(playbackScore: number): void; | ||
@@ -64,0 +71,0 @@ setConnected(isConnected: boolean): void; |
@@ -1,3 +0,3 @@ | ||
export declare const core = "@livepeer/core@1.1.3"; | ||
export declare const react = "@livepeer/react@2.1.3"; | ||
export declare const reactNative = "@livepeer/react-native@1.1.3"; | ||
export declare const core = "@livepeer/core@1.1.4"; | ||
export declare const react = "@livepeer/react@2.1.4"; | ||
export declare const reactNative = "@livepeer/react-native@1.1.4"; |
@@ -10,3 +10,3 @@ 'use strict'; | ||
var provider = require('./provider-838e9dd9.cjs.dev.js'); | ||
var src = require('./src-063c6e72.cjs.dev.js'); | ||
var src = require('./src-a8b8d361.cjs.dev.js'); | ||
var string = require('./string-0759efb1.cjs.dev.js'); | ||
@@ -13,0 +13,0 @@ var omick = require('./omick-69c95136.cjs.dev.js'); |
@@ -10,3 +10,3 @@ 'use strict'; | ||
var provider = require('./provider-f763db3e.cjs.prod.js'); | ||
var src = require('./src-5503daaa.cjs.prod.js'); | ||
var src = require('./src-6eb9f34b.cjs.prod.js'); | ||
var string = require('./string-7bb3bb00.cjs.prod.js'); | ||
@@ -13,0 +13,0 @@ var omick = require('./omick-088c0789.cjs.prod.js'); |
@@ -6,3 +6,3 @@ export { HttpError } from '../errors/dist/livepeer-core-errors.esm.js'; | ||
export { d as defaultStudioConfig, a as defaultTranscodingProfiles } from './provider-3254bb2f.esm.js'; | ||
export { c as createControllerStore, g as getMediaSourceType } from './src-71f93002.esm.js'; | ||
export { c as createControllerStore, g as getMediaSourceType } from './src-e4278ceb.esm.js'; | ||
export { b as b64Decode, a as b64Encode, c as b64UrlDecode, d as b64UrlEncode } from './string-9a973b0a.esm.js'; | ||
@@ -9,0 +9,0 @@ export { d as deepMerge, o as omit, p as pick } from './omick-f3e60faa.esm.js'; |
@@ -5,3 +5,3 @@ 'use strict'; | ||
var src = require('../../dist/src-063c6e72.cjs.dev.js'); | ||
var src = require('../../dist/src-a8b8d361.cjs.dev.js'); | ||
var fetch = require('cross-fetch'); | ||
@@ -131,13 +131,33 @@ require('zustand/middleware'); | ||
} | ||
class Timer { | ||
totalTime = 0; | ||
countStarts = 0; | ||
startTime = 0; | ||
start() { | ||
this.startTime = Date.now(); | ||
this.countStarts++; | ||
} | ||
stop() { | ||
this.totalTime += this.startTime > 0 ? Date.now() - this.startTime : 0; | ||
this.startTime = 0; | ||
} | ||
getTotalTime() { | ||
this.totalTime += this.startTime > 0 ? Date.now() - this.startTime : 0; | ||
this.startTime = this.startTime > 0 ? Date.now() : 0; | ||
return this.totalTime; | ||
} | ||
getCountStarts() { | ||
return this.countStarts; | ||
} | ||
} | ||
class MetricsStatus { | ||
requestedPlayTime = 0; | ||
retryCount = 0; | ||
connected = false; | ||
previousMetrics = null; | ||
timeWaiting = 0; | ||
waitingSince = 0; | ||
timeStalled = 0; | ||
stalledSince = 0; | ||
timeUnpaused = 0; | ||
unpausedSince = 0; | ||
timeWaiting = new Timer(); | ||
timeStalled = new Timer(); | ||
timeUnpaused = new Timer(); | ||
constructor(store) { | ||
this.requestedPlayTime = store.getState().autoplay ? Date.now() : 0; | ||
this.store = store; | ||
@@ -156,41 +176,39 @@ this.currentMetrics = { | ||
playerWidth: null, | ||
player: 'generic', | ||
player: 'livepeer-js', | ||
pageUrl: '', | ||
sourceUrl: '', | ||
playbackScore: null, | ||
duration: null | ||
duration: null, | ||
autoplay: store.getState().autoplay, | ||
userAgent: store.getState().device.userAgent, | ||
ttff: 0 | ||
}; | ||
store.subscribe((state, prevState) => { | ||
if (state._requestedPlayPauseLastTime !== prevState._requestedPlayPauseLastTime && this.requestedPlayTime === 0) { | ||
this.requestedPlayTime = state._requestedPlayPauseLastTime; | ||
} | ||
if (state.playing !== prevState.playing) { | ||
this.timeWaiting = this._getTimeWaiting(); | ||
this.timeStalled = this._getTimeStalled(); | ||
this.waitingSince = 0; | ||
this.stalledSince = 0; | ||
if (state.playing) { | ||
this.timeUnpaused = this._getTimeUnpaused(); // in case we get playing several times in a row | ||
this.unpausedSince = Date.now(); | ||
this.timeStalled.stop(); | ||
this.timeWaiting.stop(); | ||
this.timeUnpaused.start(); | ||
} else { | ||
this.timeUnpaused = this._getTimeUnpaused(); | ||
this.unpausedSince = 0; | ||
this.timeUnpaused.stop(); | ||
} | ||
} | ||
if (state.progress !== prevState.progress && !this.timeUnpaused.startTime) { | ||
this.timeStalled.stop(); | ||
this.timeWaiting.stop(); | ||
this.timeUnpaused.start(); | ||
} | ||
if (state.stalled !== prevState.stalled && state.stalled) { | ||
this.timeStalled = this._getTimeStalled(); // in case we get stalled several times in a row | ||
this.stalledSince = Date.now(); | ||
this.timeStalled.start(); | ||
this.timeUnpaused.stop(); | ||
} | ||
if (state.waiting !== prevState.waiting && state.waiting) { | ||
this.timeWaiting = this._getTimeWaiting(); // in case we get waiting several times in a row | ||
this.waitingSince = Date.now(); | ||
this.timeWaiting.start(); | ||
this.timeUnpaused.stop(); | ||
} | ||
}); | ||
} | ||
_getTimeWaiting() { | ||
return this.timeWaiting + (this.waitingSince ? Date.now() - this.waitingSince : 0); | ||
} | ||
_getTimeStalled() { | ||
return this.timeStalled + (this.stalledSince ? Date.now() - this.stalledSince : 0); | ||
} | ||
_getTimeUnpaused() { | ||
return this.timeUnpaused + (this.unpausedSince ? Date.now() - this.unpausedSince : 0); | ||
} | ||
addError(error) { | ||
@@ -200,8 +218,2 @@ this.currentMetrics.nError++; | ||
} | ||
incrementStalled() { | ||
this.currentMetrics.nStalled++; | ||
} | ||
incrementWaiting() { | ||
this.currentMetrics.nWaiting++; | ||
} | ||
getFirstPlayback() { | ||
@@ -213,2 +225,13 @@ return this.currentMetrics.firstPlayback; | ||
} | ||
getTtff() { | ||
return this.currentMetrics.ttff; | ||
} | ||
setTtff() { | ||
const ttffCalculated = Date.now() - this.requestedPlayTime; | ||
// filter out erroneous values | ||
if (ttffCalculated < 120000) { | ||
this.currentMetrics.ttff = ttffCalculated; | ||
} | ||
} | ||
setPlaybackScore(playbackScore) { | ||
@@ -228,5 +251,7 @@ this.currentMetrics.playbackScore = playbackScore; | ||
duration: this.store.getState().duration, | ||
timeWaiting: this._getTimeWaiting(), | ||
timeStalled: this._getTimeStalled(), | ||
timeUnpaused: this._getTimeUnpaused() | ||
nWaiting: this.timeWaiting.getCountStarts(), | ||
nStalled: this.timeStalled.getCountStarts(), | ||
timeWaiting: this.timeWaiting.getTotalTime(), | ||
timeStalled: this.timeStalled.getTotalTime(), | ||
timeUnpaused: this.timeUnpaused.getTotalTime() | ||
}; | ||
@@ -314,8 +339,10 @@ const previousMetrics = this.previousMetrics; | ||
} | ||
if (state.stalled !== prevState.stalled && state.stalled) { | ||
metricsStatus.incrementStalled(); | ||
// 1. When a video is above the fold and set to autoplay, ttff is from when the player is added to the HTML of the page to when the first | ||
// progress update | ||
// 2. When a video is below the fold and set to autoplay, from when lazy loading is triggered and the first progress update | ||
// 3. When a video is below the fold and not set to autoplay, from when lazy loading is triggered and the first progress update | ||
if (state.progress !== prevState.progress && metricsStatus.getTtff() === 0) { | ||
metricsStatus.setTtff(); | ||
} | ||
if (state.waiting !== prevState.waiting && state.waiting) { | ||
metricsStatus.incrementWaiting(); | ||
} | ||
if (state.error !== prevState.error && state.error) { | ||
@@ -322,0 +349,0 @@ metricsStatus.addError(state.error ?? 'unknown'); |
@@ -5,3 +5,3 @@ 'use strict'; | ||
var src = require('../../dist/src-5503daaa.cjs.prod.js'); | ||
var src = require('../../dist/src-6eb9f34b.cjs.prod.js'); | ||
var fetch = require('cross-fetch'); | ||
@@ -131,13 +131,33 @@ require('zustand/middleware'); | ||
} | ||
class Timer { | ||
totalTime = 0; | ||
countStarts = 0; | ||
startTime = 0; | ||
start() { | ||
this.startTime = Date.now(); | ||
this.countStarts++; | ||
} | ||
stop() { | ||
this.totalTime += this.startTime > 0 ? Date.now() - this.startTime : 0; | ||
this.startTime = 0; | ||
} | ||
getTotalTime() { | ||
this.totalTime += this.startTime > 0 ? Date.now() - this.startTime : 0; | ||
this.startTime = this.startTime > 0 ? Date.now() : 0; | ||
return this.totalTime; | ||
} | ||
getCountStarts() { | ||
return this.countStarts; | ||
} | ||
} | ||
class MetricsStatus { | ||
requestedPlayTime = 0; | ||
retryCount = 0; | ||
connected = false; | ||
previousMetrics = null; | ||
timeWaiting = 0; | ||
waitingSince = 0; | ||
timeStalled = 0; | ||
stalledSince = 0; | ||
timeUnpaused = 0; | ||
unpausedSince = 0; | ||
timeWaiting = new Timer(); | ||
timeStalled = new Timer(); | ||
timeUnpaused = new Timer(); | ||
constructor(store) { | ||
this.requestedPlayTime = store.getState().autoplay ? Date.now() : 0; | ||
this.store = store; | ||
@@ -156,41 +176,39 @@ this.currentMetrics = { | ||
playerWidth: null, | ||
player: 'generic', | ||
player: 'livepeer-js', | ||
pageUrl: '', | ||
sourceUrl: '', | ||
playbackScore: null, | ||
duration: null | ||
duration: null, | ||
autoplay: store.getState().autoplay, | ||
userAgent: store.getState().device.userAgent, | ||
ttff: 0 | ||
}; | ||
store.subscribe((state, prevState) => { | ||
if (state._requestedPlayPauseLastTime !== prevState._requestedPlayPauseLastTime && this.requestedPlayTime === 0) { | ||
this.requestedPlayTime = state._requestedPlayPauseLastTime; | ||
} | ||
if (state.playing !== prevState.playing) { | ||
this.timeWaiting = this._getTimeWaiting(); | ||
this.timeStalled = this._getTimeStalled(); | ||
this.waitingSince = 0; | ||
this.stalledSince = 0; | ||
if (state.playing) { | ||
this.timeUnpaused = this._getTimeUnpaused(); // in case we get playing several times in a row | ||
this.unpausedSince = Date.now(); | ||
this.timeStalled.stop(); | ||
this.timeWaiting.stop(); | ||
this.timeUnpaused.start(); | ||
} else { | ||
this.timeUnpaused = this._getTimeUnpaused(); | ||
this.unpausedSince = 0; | ||
this.timeUnpaused.stop(); | ||
} | ||
} | ||
if (state.progress !== prevState.progress && !this.timeUnpaused.startTime) { | ||
this.timeStalled.stop(); | ||
this.timeWaiting.stop(); | ||
this.timeUnpaused.start(); | ||
} | ||
if (state.stalled !== prevState.stalled && state.stalled) { | ||
this.timeStalled = this._getTimeStalled(); // in case we get stalled several times in a row | ||
this.stalledSince = Date.now(); | ||
this.timeStalled.start(); | ||
this.timeUnpaused.stop(); | ||
} | ||
if (state.waiting !== prevState.waiting && state.waiting) { | ||
this.timeWaiting = this._getTimeWaiting(); // in case we get waiting several times in a row | ||
this.waitingSince = Date.now(); | ||
this.timeWaiting.start(); | ||
this.timeUnpaused.stop(); | ||
} | ||
}); | ||
} | ||
_getTimeWaiting() { | ||
return this.timeWaiting + (this.waitingSince ? Date.now() - this.waitingSince : 0); | ||
} | ||
_getTimeStalled() { | ||
return this.timeStalled + (this.stalledSince ? Date.now() - this.stalledSince : 0); | ||
} | ||
_getTimeUnpaused() { | ||
return this.timeUnpaused + (this.unpausedSince ? Date.now() - this.unpausedSince : 0); | ||
} | ||
addError(error) { | ||
@@ -200,8 +218,2 @@ this.currentMetrics.nError++; | ||
} | ||
incrementStalled() { | ||
this.currentMetrics.nStalled++; | ||
} | ||
incrementWaiting() { | ||
this.currentMetrics.nWaiting++; | ||
} | ||
getFirstPlayback() { | ||
@@ -213,2 +225,13 @@ return this.currentMetrics.firstPlayback; | ||
} | ||
getTtff() { | ||
return this.currentMetrics.ttff; | ||
} | ||
setTtff() { | ||
const ttffCalculated = Date.now() - this.requestedPlayTime; | ||
// filter out erroneous values | ||
if (ttffCalculated < 120000) { | ||
this.currentMetrics.ttff = ttffCalculated; | ||
} | ||
} | ||
setPlaybackScore(playbackScore) { | ||
@@ -228,5 +251,7 @@ this.currentMetrics.playbackScore = playbackScore; | ||
duration: this.store.getState().duration, | ||
timeWaiting: this._getTimeWaiting(), | ||
timeStalled: this._getTimeStalled(), | ||
timeUnpaused: this._getTimeUnpaused() | ||
nWaiting: this.timeWaiting.getCountStarts(), | ||
nStalled: this.timeStalled.getCountStarts(), | ||
timeWaiting: this.timeWaiting.getTotalTime(), | ||
timeStalled: this.timeStalled.getTotalTime(), | ||
timeUnpaused: this.timeUnpaused.getTotalTime() | ||
}; | ||
@@ -314,8 +339,10 @@ const previousMetrics = this.previousMetrics; | ||
} | ||
if (state.stalled !== prevState.stalled && state.stalled) { | ||
metricsStatus.incrementStalled(); | ||
// 1. When a video is above the fold and set to autoplay, ttff is from when the player is added to the HTML of the page to when the first | ||
// progress update | ||
// 2. When a video is below the fold and set to autoplay, from when lazy loading is triggered and the first progress update | ||
// 3. When a video is below the fold and not set to autoplay, from when lazy loading is triggered and the first progress update | ||
if (state.progress !== prevState.progress && metricsStatus.getTtff() === 0) { | ||
metricsStatus.setTtff(); | ||
} | ||
if (state.waiting !== prevState.waiting && state.waiting) { | ||
metricsStatus.incrementWaiting(); | ||
} | ||
if (state.error !== prevState.error && state.error) { | ||
@@ -322,0 +349,0 @@ metricsStatus.addError(state.error ?? 'unknown'); |
@@ -1,2 +0,2 @@ | ||
export { D as DEFAULT_AUTOHIDE_TIME, a as DEFAULT_VOLUME_LEVEL, c as createControllerStore, g as getMediaSourceType } from '../../dist/src-71f93002.esm.js'; | ||
export { D as DEFAULT_AUTOHIDE_TIME, a as DEFAULT_VOLUME_LEVEL, c as createControllerStore, g as getMediaSourceType } from '../../dist/src-e4278ceb.esm.js'; | ||
import fetch from 'cross-fetch'; | ||
@@ -122,13 +122,33 @@ import 'zustand/middleware'; | ||
} | ||
class Timer { | ||
totalTime = 0; | ||
countStarts = 0; | ||
startTime = 0; | ||
start() { | ||
this.startTime = Date.now(); | ||
this.countStarts++; | ||
} | ||
stop() { | ||
this.totalTime += this.startTime > 0 ? Date.now() - this.startTime : 0; | ||
this.startTime = 0; | ||
} | ||
getTotalTime() { | ||
this.totalTime += this.startTime > 0 ? Date.now() - this.startTime : 0; | ||
this.startTime = this.startTime > 0 ? Date.now() : 0; | ||
return this.totalTime; | ||
} | ||
getCountStarts() { | ||
return this.countStarts; | ||
} | ||
} | ||
class MetricsStatus { | ||
requestedPlayTime = 0; | ||
retryCount = 0; | ||
connected = false; | ||
previousMetrics = null; | ||
timeWaiting = 0; | ||
waitingSince = 0; | ||
timeStalled = 0; | ||
stalledSince = 0; | ||
timeUnpaused = 0; | ||
unpausedSince = 0; | ||
timeWaiting = new Timer(); | ||
timeStalled = new Timer(); | ||
timeUnpaused = new Timer(); | ||
constructor(store) { | ||
this.requestedPlayTime = store.getState().autoplay ? Date.now() : 0; | ||
this.store = store; | ||
@@ -147,41 +167,39 @@ this.currentMetrics = { | ||
playerWidth: null, | ||
player: 'generic', | ||
player: 'livepeer-js', | ||
pageUrl: '', | ||
sourceUrl: '', | ||
playbackScore: null, | ||
duration: null | ||
duration: null, | ||
autoplay: store.getState().autoplay, | ||
userAgent: store.getState().device.userAgent, | ||
ttff: 0 | ||
}; | ||
store.subscribe((state, prevState) => { | ||
if (state._requestedPlayPauseLastTime !== prevState._requestedPlayPauseLastTime && this.requestedPlayTime === 0) { | ||
this.requestedPlayTime = state._requestedPlayPauseLastTime; | ||
} | ||
if (state.playing !== prevState.playing) { | ||
this.timeWaiting = this._getTimeWaiting(); | ||
this.timeStalled = this._getTimeStalled(); | ||
this.waitingSince = 0; | ||
this.stalledSince = 0; | ||
if (state.playing) { | ||
this.timeUnpaused = this._getTimeUnpaused(); // in case we get playing several times in a row | ||
this.unpausedSince = Date.now(); | ||
this.timeStalled.stop(); | ||
this.timeWaiting.stop(); | ||
this.timeUnpaused.start(); | ||
} else { | ||
this.timeUnpaused = this._getTimeUnpaused(); | ||
this.unpausedSince = 0; | ||
this.timeUnpaused.stop(); | ||
} | ||
} | ||
if (state.progress !== prevState.progress && !this.timeUnpaused.startTime) { | ||
this.timeStalled.stop(); | ||
this.timeWaiting.stop(); | ||
this.timeUnpaused.start(); | ||
} | ||
if (state.stalled !== prevState.stalled && state.stalled) { | ||
this.timeStalled = this._getTimeStalled(); // in case we get stalled several times in a row | ||
this.stalledSince = Date.now(); | ||
this.timeStalled.start(); | ||
this.timeUnpaused.stop(); | ||
} | ||
if (state.waiting !== prevState.waiting && state.waiting) { | ||
this.timeWaiting = this._getTimeWaiting(); // in case we get waiting several times in a row | ||
this.waitingSince = Date.now(); | ||
this.timeWaiting.start(); | ||
this.timeUnpaused.stop(); | ||
} | ||
}); | ||
} | ||
_getTimeWaiting() { | ||
return this.timeWaiting + (this.waitingSince ? Date.now() - this.waitingSince : 0); | ||
} | ||
_getTimeStalled() { | ||
return this.timeStalled + (this.stalledSince ? Date.now() - this.stalledSince : 0); | ||
} | ||
_getTimeUnpaused() { | ||
return this.timeUnpaused + (this.unpausedSince ? Date.now() - this.unpausedSince : 0); | ||
} | ||
addError(error) { | ||
@@ -191,8 +209,2 @@ this.currentMetrics.nError++; | ||
} | ||
incrementStalled() { | ||
this.currentMetrics.nStalled++; | ||
} | ||
incrementWaiting() { | ||
this.currentMetrics.nWaiting++; | ||
} | ||
getFirstPlayback() { | ||
@@ -204,2 +216,13 @@ return this.currentMetrics.firstPlayback; | ||
} | ||
getTtff() { | ||
return this.currentMetrics.ttff; | ||
} | ||
setTtff() { | ||
const ttffCalculated = Date.now() - this.requestedPlayTime; | ||
// filter out erroneous values | ||
if (ttffCalculated < 120000) { | ||
this.currentMetrics.ttff = ttffCalculated; | ||
} | ||
} | ||
setPlaybackScore(playbackScore) { | ||
@@ -219,5 +242,7 @@ this.currentMetrics.playbackScore = playbackScore; | ||
duration: this.store.getState().duration, | ||
timeWaiting: this._getTimeWaiting(), | ||
timeStalled: this._getTimeStalled(), | ||
timeUnpaused: this._getTimeUnpaused() | ||
nWaiting: this.timeWaiting.getCountStarts(), | ||
nStalled: this.timeStalled.getCountStarts(), | ||
timeWaiting: this.timeWaiting.getTotalTime(), | ||
timeStalled: this.timeStalled.getTotalTime(), | ||
timeUnpaused: this.timeUnpaused.getTotalTime() | ||
}; | ||
@@ -305,8 +330,10 @@ const previousMetrics = this.previousMetrics; | ||
} | ||
if (state.stalled !== prevState.stalled && state.stalled) { | ||
metricsStatus.incrementStalled(); | ||
// 1. When a video is above the fold and set to autoplay, ttff is from when the player is added to the HTML of the page to when the first | ||
// progress update | ||
// 2. When a video is below the fold and set to autoplay, from when lazy loading is triggered and the first progress update | ||
// 3. When a video is below the fold and not set to autoplay, from when lazy loading is triggered and the first progress update | ||
if (state.progress !== prevState.progress && metricsStatus.getTtff() === 0) { | ||
metricsStatus.setTtff(); | ||
} | ||
if (state.waiting !== prevState.waiting && state.waiting) { | ||
metricsStatus.incrementWaiting(); | ||
} | ||
if (state.error !== prevState.error && state.error) { | ||
@@ -313,0 +340,0 @@ metricsStatus.addError(state.error ?? 'unknown'); |
@@ -5,3 +5,3 @@ { | ||
"license": "MIT", | ||
"version": "1.1.3", | ||
"version": "1.1.4", | ||
"repository": { | ||
@@ -8,0 +8,0 @@ "type": "git", |
@@ -33,5 +33,5 @@ 'use strict'; | ||
const core = `@livepeer/core@1.1.3`; | ||
const react = `@livepeer/react@2.1.3`; | ||
const reactNative = `@livepeer/react-native@1.1.3`; | ||
const core = `@livepeer/core@1.1.4`; | ||
const react = `@livepeer/react@2.1.4`; | ||
const reactNative = `@livepeer/react-native@1.1.4`; | ||
@@ -38,0 +38,0 @@ class BaseLivepeerProvider { |
@@ -33,5 +33,5 @@ 'use strict'; | ||
const core = `@livepeer/core@1.1.3`; | ||
const react = `@livepeer/react@2.1.3`; | ||
const reactNative = `@livepeer/react-native@1.1.3`; | ||
const core = `@livepeer/core@1.1.4`; | ||
const react = `@livepeer/react@2.1.4`; | ||
const reactNative = `@livepeer/react-native@1.1.4`; | ||
@@ -38,0 +38,0 @@ class BaseLivepeerProvider { |
@@ -6,5 +6,5 @@ import * as tus from 'tus-js-client'; | ||
const core = `@livepeer/core@1.1.3`; | ||
const react = `@livepeer/react@2.1.3`; | ||
const reactNative = `@livepeer/react-native@1.1.3`; | ||
const core = `@livepeer/core@1.1.4`; | ||
const react = `@livepeer/react@2.1.4`; | ||
const reactNative = `@livepeer/react-native@1.1.4`; | ||
@@ -11,0 +11,0 @@ class BaseLivepeerProvider { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
833629
33644