Skip to content

Commit

Permalink
feat: kava plugin (#1)
Browse files Browse the repository at this point in the history
Kava plugin implementation
  • Loading branch information
Dan Ziv authored May 27, 2018
1 parent 6db448d commit adf4609
Show file tree
Hide file tree
Showing 33 changed files with 9,662 additions and 1 deletion.
16 changes: 16 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"presets": [
"es2015"
],
"plugins": [
"transform-flow-strip-types",
"transform-class-properties"
],
"env": {
"test": {
"plugins": [
"istanbul"
]
}
}
}
10 changes: 10 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# http://editorconfig.org
root = true

[*]
charset = utf-8
indent_size = 2
end_of_line = lf
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true
5 changes: 5 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/flow-typed/**/*.js
/coverage
/dist
karma.conf.js
webpack.config.js
34 changes: 34 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"parser": "babel-eslint",
"extends": [
"eslint:recommended",
"plugin:flowtype/recommended"
],
"plugins": [
"import",
"flowtype",
"mocha-no-only"
],
"env": {
"browser": true,
"es6": true,
"mocha": true,
"amd": true,
"commonjs": true
},
"globals": {
"should": true,
"sinon": true,
"__VERSION__": true,
"__NAME__": true
},
"rules": {
"mocha-no-only/mocha-no-only": "off",
"require-jsdoc": [
"error"
],
"valid-jsdoc": [
"error"
]
}
}
10 changes: 10 additions & 0 deletions .flowconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[ignore]
.*/node_modules/conventional-changelog-core/test/fixtures/_malformation.json
.*/node_modules/playkit-js/src/
.*/node_modules/playkit-js-providers/src/
[include]
[libs]
node_modules/playkit-js/flow-typed/
node_modules/playkit-js-providers/flow-typed/
[options]
unsafe.enable_getters_and_setters=true
26 changes: 26 additions & 0 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<!-- If you are raising a bug playing a stream, you must fill out the following or your issue may not be responded to. For features or improvements, you may delete this. -->
##### Prerequisites
- [ ] Have you checked for duplicate [issues](https://github.com/kaltura/playkit-js/issues): ______
- [ ] Which Player [version](https://github.com/kaltura/playkit-js/releases) are you using: ______
- [ ] Can you reproduce the issue with our latest release version: ______
- [ ] Can you reproduce the issue with the latest code from master: ______
- [ ] What browser and OS names and versions are you using: ______
- [ ] If applicable, add test code or test page to reproduce:
```
Paste test code here
```

##### Expected behavior
What you expected to happen

##### Actual behavior
What actually happened

##### Console output
```
Paste the contents of the browser console here.
```

```
For media errors reported on Chrome browser, please also paste the output of chrome://media-internals
```
12 changes: 12 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
### Description of the Changes

Please add a detailed description of the change, weather it's an enhancement or a bugfix.
If the PR is related to an open issue please link to it.

### CheckLists

- [ ] changes have been done against master branch, and PR does not conflict
- [ ] new unit / functional tests have been added (whenever applicable)
- [ ] test are passing in local environment
- [ ] Travis tests are passing (or test results are not worse than on master branch :))
- [ ] Docs have been updated
41 changes: 41 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Logs
logs
*.log
npm-debug.log*

# Runtime data
pids
*.pid
*.seed

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# node-waf configuration
.lock-wscript

# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules
jspm_packages

# Optional npm cache directory
.npm

# Optional REPL history
.node_repl_history

.idea/

/dist/
24 changes: 24 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
sudo: required
dist: trusty
language: node_js
node_js:
- "node"

cache:
yarn: true
directories:
- node_modules

before_install:
- export CHROME_BIN=/usr/bin/google-chrome
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start
- sudo apt-get update
- sudo apt-get install -y libappindicator1 fonts-liberation
- wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
- sudo dpkg -i google-chrome*.deb

script:
- npm run eslint
- npm run flow
- npm run test
114 changes: 113 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,113 @@
# playkit-js-kava
# PlayKit JS Kava - Kaltura Advanced Video Analytics Plugin for the [PlayKit JS Player]

[![Build Status](https://travis-ci.org/kaltura/playkit-js-kava.svg?branch=master)](https://travis-ci.org/kaltura/playkit-js-kava)

PlayKit JS Kava plugin integrates Kava (Kaltura Advanced Video Analytics) with the [PlayKit JS Player].

The main purpose of this plugin is to track and collect various events and data about the video player.

PlayKit JS Kava is written in [ECMAScript6], statically analysed using [Flow] and transpiled in ECMAScript5 using [Babel].

[Flow]: https://flow.org/
[ECMAScript6]: https://github.com/ericdouglas/ES6-Learning#articles--tutorials
[Babel]: https://babeljs.io

## Getting Started

### Prerequisites
The plugin requires [PlayKit JS Player] to be loaded first.

[Playkit JS Player]: https://github.com/kaltura/playkit-js

### Installing

First, clone and run [yarn] to install dependencies:

[yarn]: https://yarnpkg.com/lang/en/

```
git clone https://github.com/kaltura/playkit-js-kava.git
cd playkit-js-kava
yarn install
```

### Building

Then, build the player

```javascript
yarn run build
```

### Embed the Library In Your Test Page

Finally, add the bundle as a script tag in your page, and initialize the player

```html
<script type="text/javascript" src="/PATH/TO/FILE/playkit.js"></script>
<script type="text/javascript" src="/PATH/TO/FILE/playkit-kava.js"></script>
<div id="player-placeholder" style="height:360px; width:640px">
<script type="text/javascript">
var playerContainer = document.querySelector("#player-placeholder");
var config = {
...
plugins: {
kava: {
...
}
}
...
};
var player = playkit.core.loadPlayer(config);
playerContainer.appendChild(player.getView());
player.play();
</script>
```

## Documentation

### Table of Contents
- [Configuration](./docs/configuration.md)
- [Events](./docs/kava-events.md)
- [Parameters](./docs/kava-parameters.md)

## Running the Tests

Tests can be run locally via [Karma], which will run on Chrome, Firefox and Safari.

[Karma]: https://karma-runner.github.io/1.0/index.html
```
yarn run test
```

You can test individual browsers:
```
yarn run test:chrome
yarn run test:firefox
yarn run test:safari
```

### And Coding Style Tests

We use ESLint [recommended set](http://eslint.org/docs/rules/) with some additions for enforcing [Flow] types and other rules.

See [ESLint config](.eslintrc.json) for full configuration.

We also use [.editorconfig](.editorconfig) to maintain consistent coding styles and settings, please make sure you comply with the styling.


## Compatibility

TBD

## Contributing

Please read [CONTRIBUTING.md](https://gist.github.com/PurpleBooth/b24679402957c63ec426) for details on our code of conduct, and the process for submitting pull requests to us.

## Versioning

We use [SemVer](http://semver.org/) for versioning. For the versions available, see the [tags on this repository](https://github.com/kaltura/playkit-js-kanalytics/tags).

## License

This project is licensed under the AGPL-3.0 License - see the [LICENSE.md](LICENSE.md) file for details
52 changes: 52 additions & 0 deletions docs/configuration.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Configuration

### Structure
```js
{
serviceUrl: string,
viewEventCountdown: number,
resetSessionCountdown: number,
dvrThreshold: number,
customVar1: Object,
customVar2: Object,
customVar3: Object
}
```

### Default Values
```js
{
serviceUrl: '//analytics.kaltura.com/api_v3/index.php',
viewEventCountdown: 10,
resetSessionCountdown: 30,
dvrThreshold: 120000
}
```

##
>### config.serviceUrl
>##### Type: `string`
>##### Default: `'//analytics.kaltura.com/api_v3/index.php'`
>##### Description: The Kaltura API server.
##
>### config.viewEventCountdown
>##### Type: `number`
>##### Default: `10`
>##### Description: The interval in seconds that VIEW event will be sent.
##
>### config.resetSessionCountdown
>##### Type: `number`
>##### Default: `30`
>##### Description: The interval in seconds that Kava session will be reset.
##
>### config.dvrThreshold
>##### Type: `number`
>##### Default: `120000`
>##### Description: Threshold in milliseconds from the live edge.
>When player's playback position from the live edge <= then dvrThreshold, Kava will set playbackType to dvr. Otherwise it will be live.
##
>### config.customVar1/customVar2/customVar3
>##### Type: `any`
>##### Default: `-`
>##### Description: Custom objects fields.
>You can use these fields for your own custom needs.
Loading

0 comments on commit adf4609

Please sign in to comment.