Skip to content

Commit

Permalink
feat(FEC-9652): report playbackSpeed and caption in all events (#66)
Browse files Browse the repository at this point in the history
playbackSpeed and caption have been moved to common (for all events)
added check to send the proprty only if captions exist
removed captionLanguage property from VIEW
Changed unit tests to support the change
Docs changed accordingly
  • Loading branch information
RoyBregman authored Mar 1, 2020
1 parent 861a3d0 commit 40b8250
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 32 deletions.
9 changes: 3 additions & 6 deletions docs/kava-events.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

---

Expand Down Expand Up @@ -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)

---

Expand All @@ -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)

---

Expand Down
2 changes: 2 additions & 0 deletions docs/kava-parameters.md
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,8 @@ 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)
Expand Down
19 changes: 9 additions & 10 deletions src/kava-event-model.js
Original file line number Diff line number Diff line change
Expand Up @@ -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())) {
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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.caption = model.getCaption();
}
if (model.getSessionStartTime()) {
commonModel.sessionStartTime = model.getSessionStartTime();
}
Expand Down
8 changes: 1 addition & 7 deletions test/src/kava-event-model.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand All @@ -134,8 +133,7 @@ describe('KavaEventModel', () => {
targetBuffer: fakeModel.getTargetBuffer(),
networkConnectionType: fakeModel.getNetworkConnectionType(),
networkConnectionOverhead: fakeModel.getNetworkConnectionOverhead(),
flavorParamsId: fakeModel.getFlavorParamsId(),
playbackSpeed: fakeModel.getPlaybackSpeed()
flavorParamsId: fakeModel.getFlavorParamsId()
});
});

Expand Down Expand Up @@ -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', () => {
Expand Down Expand Up @@ -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});
});
});
11 changes: 8 additions & 3 deletions test/src/kava-model.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ const ab = 3,
tp = '12',
pc = 'pc',
av = 'av',
usi = '1234';
usi = '1234',
pbs = 1;

describe('KavaModel', () => {
let model;
Expand Down Expand Up @@ -58,7 +59,8 @@ describe('KavaModel', () => {
caption: cap,
errorCode: ec,
joinTime: jt,
targetPosition: tp
targetPosition: tp,
playbackSpeed: pbs
});
model.getActualBitrate = () => ab;
model.getAverageBitrate = () => avb;
Expand All @@ -81,6 +83,7 @@ describe('KavaModel', () => {
model.getPlaybackContext = () => pc;
model.getApplicationVersion = () => av;
model.getUserId = () => usi;
model.getPlaybackSpeed = () => pbs;
});

it('should update the model', function() {
Expand Down Expand Up @@ -114,7 +117,9 @@ describe('KavaModel', () => {
customVar2: cv2,
playbackContext: pc,
applicationVer: av,
userId: usi
userId: usi,
playbackSpeed: pbs,
caption: cap
});
});
});
9 changes: 6 additions & 3 deletions test/src/kava.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand Down Expand Up @@ -626,7 +627,7 @@ describe('KavaPlugin', function() {
'bufferTimeSum',
'actualBitrate',
'averageBitrate',
'captionsLanguage',
'caption',
'clientTag',
'clientVer',
'deliveryType',
Expand All @@ -636,6 +637,7 @@ describe('KavaPlugin', function() {
'eventType',
'ks',
'partnerId',
'playbackSpeed',
'playTimeSum',
'playbackType',
'playlistId',
Expand All @@ -645,8 +647,7 @@ describe('KavaPlugin', function() {
'soundMode',
'tabMode',
'networkConnectionType',
'userId',
'playbackSpeed'
'userId'
);
params.networkConnectionType.should.equal('2g');
params.tabMode.should.equal(TabMode.TAB_FOCUSED);
Expand All @@ -659,6 +660,8 @@ describe('KavaPlugin', function() {
}
});
setupPlayer(config);
kava = getKavaPlugin();
kava._model.updateModel({caption: 'eng'});
player.play();
});

Expand Down
6 changes: 3 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 40b8250

Please sign in to comment.