Skip to content

Commit

Permalink
feat(pillarbox-monitoring): add frame drops
Browse files Browse the repository at this point in the history
Resolves #269, sending the number of frame drops during the media playback
session.

- adds `frame_drops` property
- adds the `getVideoPlaybackQuality` function to the player mock
  • Loading branch information
amtins committed Oct 14, 2024
1 parent acf45d4 commit ec67109
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/trackers/PillarboxMonitoring.js
Original file line number Diff line number Diff line change
Expand Up @@ -731,6 +731,7 @@ class PillarboxMonitoring {
* @property {number} bandwidth The current bandwidth
* @property {number|undefined} bitrate The bitrate of the current resource
* @property {number} buffered_duration The duration of the buffered content
* @property {number} frame_drops The number of dropped frames
* @property {number} playback_duration The duration of the playback
* @property {number} position The current playback position
* @property {number} position_timestamp The timestamp of the current playback position
Expand All @@ -744,6 +745,9 @@ class PillarboxMonitoring {
const bandwidth = this.bandwidth();
const buffered_duration = this.bufferDuration();
const { bitrate, url } = this.currentResource();
const {
droppedVideoFrames: frame_drops
} = this.player.getVideoPlaybackQuality();
const playback_duration = this.playbackDuration();
const { position, position_timestamp } = this.playbackPosition();
const stream_type = isFinite(this.player.duration()) ? 'On-demand' : 'Live';
Expand All @@ -753,6 +757,7 @@ class PillarboxMonitoring {
bandwidth,
bitrate,
buffered_duration,
frame_drops,
playback_duration,
position,
position_timestamp,
Expand Down
1 change: 1 addition & 0 deletions test/__mocks__/player-mock.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ let playerMock = jest.fn(() => ({

return err;
}),
getVideoPlaybackQuality: jest.fn().mockReturnValue({}),
hasStarted: jest.fn(),
muted: jest.fn(),
play: jest.fn(() => {
Expand Down

0 comments on commit ec67109

Please sign in to comment.