From 3ae8332b03f2fc3447f926688c9024f089bc7d20 Mon Sep 17 00:00:00 2001 From: Roy Bregman Date: Mon, 24 Feb 2020 18:23:46 +0200 Subject: [PATCH 1/4] feat(FEC-9652): report playbackSpeed and captionsLanguage in all events --- src/kava-event-model.js | 19 +++++++++---------- test/src/kava-event-model.spec.js | 8 +------- test/src/kava-model.spec.js | 11 ++++++++--- test/src/kava.spec.js | 1 + yarn.lock | 6 +++--- 5 files changed, 22 insertions(+), 23 deletions(-) diff --git a/src/kava-event-model.js b/src/kava-event-model.js index 178e7b25..d6fdca33 100644 --- a/src/kava-event-model.js +++ b/src/kava-event-model.js @@ -21,10 +21,8 @@ export const KavaEventModel: {[event: string]: KavaEvent} = { actualBitrate: model.getActualBitrate(), averageBitrate: model.getAverageBitrate(), audioLanguage: model.getLanguage(), - captionsLanguage: model.getCaption(), soundMode: model.getSoundMode(), - tabMode: model.getTabMode(), - playbackSpeed: model.getPlaybackSpeed() + tabMode: model.getTabMode() }; if (!isNaN(model.getForwardBufferHealth())) { @@ -242,9 +240,7 @@ export const KavaEventModel: {[event: string]: KavaEvent} = { SPEED: { type: 'SPEED', index: 41, - getEventModel: (model: KavaModel) => ({ - playbackSpeed: model.getPlaybackSpeed() - }) + getEventModel: () => ({}) }, /** * @type {string} CAPTIONS @@ -253,9 +249,7 @@ export const KavaEventModel: {[event: string]: KavaEvent} = { CAPTIONS: { type: 'CAPTIONS', index: 38, - getEventModel: (model: KavaModel) => ({ - caption: model.getCaption() - }) + getEventModel: () => ({}) }, /** * @type {string} ERROR @@ -296,8 +290,13 @@ export function getEventModel(eventObj: KavaEvent, model: KavaModel): Object { playbackType: model.getPlaybackType(), clientVer: model.getClientVer(), clientTag: model.getClientTag(), - position: model.getPosition() + position: model.getPosition(), + playbackSpeed: model.getPlaybackSpeed() }; + + if (model.getCaption()) { + commonModel.captionsLanguage = model.getCaption(); + } if (model.getSessionStartTime()) { commonModel.sessionStartTime = model.getSessionStartTime(); } diff --git a/test/src/kava-event-model.spec.js b/test/src/kava-event-model.spec.js index c52c53db..7130a9cc 100644 --- a/test/src/kava-event-model.spec.js +++ b/test/src/kava-event-model.spec.js @@ -122,7 +122,6 @@ describe('KavaEventModel', () => { bufferTimeSum: fakeModel.getBufferTimeSum(), actualBitrate: fakeModel.getActualBitrate(), averageBitrate: fakeModel.getAverageBitrate(), - captionsLanguage: fakeModel.getCaption(), audioLanguage: fakeModel.getLanguage(), bandwidth: fakeModel.getBandwidth(), droppedFramesRatio: fakeModel.getDroppedFramesRatio(), @@ -134,8 +133,7 @@ describe('KavaEventModel', () => { targetBuffer: fakeModel.getTargetBuffer(), networkConnectionType: fakeModel.getNetworkConnectionType(), networkConnectionOverhead: fakeModel.getNetworkConnectionOverhead(), - flavorParamsId: fakeModel.getFlavorParamsId(), - playbackSpeed: fakeModel.getPlaybackSpeed() + flavorParamsId: fakeModel.getFlavorParamsId() }); }); @@ -247,9 +245,6 @@ describe('KavaEventModel', () => { it('CAPTIONS', () => { KavaEventModel.CAPTIONS.type.should.equal('CAPTIONS'); KavaEventModel.CAPTIONS.index.should.equal(38); - KavaEventModel.CAPTIONS.getEventModel(fakeModel).should.deep.equal({ - caption: fakeModel.getCaption() - }); }); it('ERROR', () => { @@ -277,6 +272,5 @@ describe('KavaEventModel', () => { it('SPEED', () => { KavaEventModel.SPEED.type.should.equal('SPEED'); KavaEventModel.SPEED.index.should.equal(41); - KavaEventModel.SPEED.getEventModel(fakeModel).should.deep.equal({playbackSpeed: 2}); }); }); diff --git a/test/src/kava-model.spec.js b/test/src/kava-model.spec.js index 74fb2613..103aa9b0 100644 --- a/test/src/kava-model.spec.js +++ b/test/src/kava-model.spec.js @@ -29,7 +29,8 @@ const ab = 3, tp = '12', pc = 'pc', av = 'av', - usi = '1234'; + usi = '1234', + pbs = 1; describe('KavaModel', () => { let model; @@ -58,7 +59,8 @@ describe('KavaModel', () => { caption: cap, errorCode: ec, joinTime: jt, - targetPosition: tp + targetPosition: tp, + playbackSpeed: pbs }); model.getActualBitrate = () => ab; model.getAverageBitrate = () => avb; @@ -81,6 +83,7 @@ describe('KavaModel', () => { model.getPlaybackContext = () => pc; model.getApplicationVersion = () => av; model.getUserId = () => usi; + model.getPlaybackSpeed = () => pbs; }); it('should update the model', function() { @@ -114,7 +117,9 @@ describe('KavaModel', () => { customVar2: cv2, playbackContext: pc, applicationVer: av, - userId: usi + userId: usi, + playbackSpeed: pbs, + captionsLanguage: cap }); }); }); diff --git a/test/src/kava.spec.js b/test/src/kava.spec.js index 158a8ff0..cc3224a9 100644 --- a/test/src/kava.spec.js +++ b/test/src/kava.spec.js @@ -153,6 +153,7 @@ describe('KavaPlugin', function() { params.clientTag.should.equal('html5:v' + config.plugins.kava.playerVersion); params.position.should.exist; params.userId.should.equal(config.plugins.kava.userId); + params.playbackSpeed.should.equal(1); } it('should send IMPRESSION event', done => { diff --git a/yarn.lock b/yarn.lock index 8823948d..876d2767 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3,9 +3,9 @@ "@playkit-js/playkit-js@^0.59.5": - version "0.59.5-canary.e472628" - resolved "https://registry.yarnpkg.com/@playkit-js/playkit-js/-/playkit-js-0.59.5-canary.e472628.tgz#a29538f69ffa9e9b6ba3e6d1573ebefc2ab6b435" - integrity sha512-GigercssRC1K0rxnjNIXhCsc9QF68/5mOIDyKqX8OqO5g7eHl8nRSsWg0nFHfFNtpo/IJXtRwrEneIca0vEMAw== + version "0.59.9" + resolved "https://registry.yarnpkg.com/@playkit-js/playkit-js/-/playkit-js-0.59.9.tgz#af589c1cf39570baf494e9fb1ca0021fbda49cce" + integrity sha512-lJKj5qNqksrIPSqReyHpE/YXcgDQOTO0prD7adPXCaDZZ270b1HpW60YiCGoRnNyrYmYQdkZETp0jv3lBh15jw== dependencies: js-logger "^1.3.0" ua-parser-js "^0.7.13" From cfbc0e0f4e8b70e84eb58e98eb699d9274d4d1a8 Mon Sep 17 00:00:00 2001 From: Roy Bregman Date: Mon, 24 Feb 2020 18:31:12 +0200 Subject: [PATCH 2/4] docs --- docs/kava-events.md | 9 +++------ docs/kava-parameters.md | 2 ++ 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/docs/kava-events.md b/docs/kava-events.md index e9923c0f..5aaa34cb 100644 --- a/docs/kava-events.md +++ b/docs/kava-events.md @@ -49,11 +49,10 @@ Here we will see some explanation about each event. When does it sent and what p - [`networkConnectionType`](./kava-parameters.md#networkConnectionType) - [`networkConnectionOverhead`](./kava-parameters.md#networkConnectionOverhead) - [`flavorParamsId`](./kava-parameters.md#flavorParamsId) - - [`playbackSpeed`](./kava-parameters.md#playbackSpeed) -- Sent on first play and every 10 seconds of active playback (when player is paused, view timer should be paused/stopped). -- 30 seconds without VIEW event will reset KAVA session, so all the VIEW [specific parameters](#endSessionResetParams) should be reset also. -- Server may notify Kava (via response field ["viewEventsEnabled" = false](#serverResponse)) to shut down VIEW events. When it happens, VIEW events should be blocked from sending until server decides to enable VIEW events again. +* Sent on first play and every 10 seconds of active playback (when player is paused, view timer should be paused/stopped). +* 30 seconds without VIEW event will reset KAVA session, so all the VIEW [specific parameters](#endSessionResetParams) should be reset also. +* Server may notify Kava (via response field ["viewEventsEnabled" = false](#serverResponse)) to shut down VIEW events. When it happens, VIEW events should be blocked from sending until server decides to enable VIEW events again. --- @@ -224,7 +223,6 @@ No matter if by seeking or regular playback. - Player Event: `TEXT_TRACK_CHANGED` - Event Parameters: - [`COMMON_PARAMS`](./kava-parameters.md#common_params) - - [`caption`](./kava-parameters.md#caption) --- @@ -234,7 +232,6 @@ No matter if by seeking or regular playback. - Player Event: `RATE_CHANGE` - Event Parameters: - [`COMMON_PARAMS`](./kava-parameters.md#common_params) - - [`playbackSpeed`](./kava-parameters.md#playbackSpeed) --- diff --git a/docs/kava-parameters.md b/docs/kava-parameters.md index 6c713683..fa88e6ac 100644 --- a/docs/kava-parameters.md +++ b/docs/kava-parameters.md @@ -331,6 +331,8 @@ The common parameters defined the following: - [`customVar1`](#customVar1) - [`customVar2`](#customVar2) - [`customVar3`](#customVar3) +- [`playbackSpeed`](#playbackSpeed) +- [`caption`](#caption) ## End Session Reset Parameters From e3c426868fa9e7acece449d4167808525cc4fcd7 Mon Sep 17 00:00:00 2001 From: Roy Bregman Date: Sun, 1 Mar 2020 14:26:43 +0200 Subject: [PATCH 3/4] after talking to Nadav --- src/kava-event-model.js | 2 +- test/src/kava-model.spec.js | 2 +- test/src/kava.spec.js | 8 +++++--- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/kava-event-model.js b/src/kava-event-model.js index d6fdca33..4db2b172 100644 --- a/src/kava-event-model.js +++ b/src/kava-event-model.js @@ -295,7 +295,7 @@ export function getEventModel(eventObj: KavaEvent, model: KavaModel): Object { }; if (model.getCaption()) { - commonModel.captionsLanguage = model.getCaption(); + commonModel.caption = model.getCaption(); } if (model.getSessionStartTime()) { commonModel.sessionStartTime = model.getSessionStartTime(); diff --git a/test/src/kava-model.spec.js b/test/src/kava-model.spec.js index 103aa9b0..e919b147 100644 --- a/test/src/kava-model.spec.js +++ b/test/src/kava-model.spec.js @@ -119,7 +119,7 @@ describe('KavaModel', () => { applicationVer: av, userId: usi, playbackSpeed: pbs, - captionsLanguage: cap + caption: cap }); }); }); diff --git a/test/src/kava.spec.js b/test/src/kava.spec.js index cc3224a9..de6de664 100644 --- a/test/src/kava.spec.js +++ b/test/src/kava.spec.js @@ -627,7 +627,7 @@ describe('KavaPlugin', function() { 'bufferTimeSum', 'actualBitrate', 'averageBitrate', - 'captionsLanguage', + 'caption', 'clientTag', 'clientVer', 'deliveryType', @@ -637,6 +637,7 @@ describe('KavaPlugin', function() { 'eventType', 'ks', 'partnerId', + 'playbackSpeed', 'playTimeSum', 'playbackType', 'playlistId', @@ -646,8 +647,7 @@ describe('KavaPlugin', function() { 'soundMode', 'tabMode', 'networkConnectionType', - 'userId', - 'playbackSpeed' + 'userId' ); params.networkConnectionType.should.equal('2g'); params.tabMode.should.equal(TabMode.TAB_FOCUSED); @@ -660,6 +660,8 @@ describe('KavaPlugin', function() { } }); setupPlayer(config); + kava = getKavaPlugin(); + kava._model.updateModel({caption: 'eng'}); player.play(); }); From cc2eb8f950182b697c644e9fdaca4deaca6f1df4 Mon Sep 17 00:00:00 2001 From: Roy Bregman Date: Sun, 1 Mar 2020 14:54:35 +0200 Subject: [PATCH 4/4] fixing docs --- docs/kava-parameters.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/kava-parameters.md b/docs/kava-parameters.md index fa88e6ac..fae1e2ba 100644 --- a/docs/kava-parameters.md +++ b/docs/kava-parameters.md @@ -328,11 +328,11 @@ The common parameters defined the following: - [`clientVer`](#clientVer) - [`clientTag`](#clientTag) - [`position`](#position) +- [`playbackSpeed`](#playbackSpeed) +- [`caption`](#caption) - optional, available only if video contains text tracks - [`customVar1`](#customVar1) - [`customVar2`](#customVar2) - [`customVar3`](#customVar3) -- [`playbackSpeed`](#playbackSpeed) -- [`caption`](#caption) ## End Session Reset Parameters