Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(FEC-9652): report playbackSpeed and captionsLanguage in all events #66

Merged
merged 4 commits into from
Mar 1, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -331,6 +331,8 @@ The common parameters defined the following:
- [`customVar1`](#customVar1)
- [`customVar2`](#customVar2)
- [`customVar3`](#customVar3)
- [`playbackSpeed`](#playbackSpeed)
- [`caption`](#caption)

## <a id="endSessionResetParams"></a>End Session Reset Parameters

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.captionsLanguage = 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,
captionsLanguage: cap
});
});
});
1 change: 1 addition & 0 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
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