@playkit-js/rapt 0.4.10-canary.0-878cdb7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json ADDED
@@ -0,0 +1,75 @@
1
+ {
2
+ "name": "@playkit-js/rapt",
3
+ "version": "0.4.10-canary.0-878cdb7",
4
+ "description": "Kaltura Interactive player based on Rapt engine",
5
+ "main": "index.js",
6
+ "license": "AGPL-3.0",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/kaltura/kaltura-interactive-player.git"
10
+ },
11
+ "keywords": [
12
+ "kaltura",
13
+ "interactive-video"
14
+ ],
15
+ "author": {
16
+ "name": "Kaltura Community",
17
+ "email": "community@kaltura.com"
18
+ },
19
+ "contributors": [
20
+ {
21
+ "name": "Jonathan Golad",
22
+ "email": "jonathan.gold@kaltura.com"
23
+ },
24
+ {
25
+ "name": "Lian Binyamin",
26
+ "email": "lian.binyamin@kaltura.com"
27
+ },
28
+ {
29
+ "name": "Sivan Agranov",
30
+ "email": "sivan.agranov@kaltura.com"
31
+ }
32
+ ],
33
+ "scripts": {
34
+ "tag": "scripts/tag.sh",
35
+ "start": "webpack --watch & webpack-dev-server --dev",
36
+ "serve-external": "webpack --watch & webpack-dev-server --host 0.0.0.0 --dev",
37
+ "clean": "rm -rf ./dist",
38
+ "tgz": "node scripts/dist-tgz.js",
39
+ "prebuild": "npm run clean",
40
+ "prebuild:dev": "npm run clean",
41
+ "prestart": "npm run clean",
42
+ "pushTaggedRelease": "git push --follow-tags --no-verify origin master",
43
+ "release": "standard-version",
44
+ "build": "node scripts/dist-tgz.js && webpack --mode production",
45
+ "build:dev": "webpack"
46
+ },
47
+ "dependencies": {
48
+ "kaltura-typescript-client": "file:libs/kaltura-typescript-client-7.0.1-v20200720-164020.tgz",
49
+ "node-sass": "^4.14.1",
50
+ "tslib": "^2.5.0"
51
+ },
52
+ "devDependencies": {
53
+ "@types/node": "^14.11.2",
54
+ "@types/core-js": "^2.5.0",
55
+ "archiver": "^3.0.0",
56
+ "core-js": "^2.5.7",
57
+ "css-loader": "^1.0.0",
58
+ "node-fetch": "^2.2.0",
59
+ "sass-loader": "^7.1.0",
60
+ "script-loader": "^0.7.2",
61
+ "style-loader": "^0.23.1",
62
+ "ts-loader": "^4.4.2",
63
+ "typescript": "^3.0.1",
64
+ "uglifyjs-webpack-plugin": "^2.0.1",
65
+ "standard-version": "^6.0.1",
66
+ "webpack": "^4.41.6",
67
+ "webpack-cli": "^3.1.0",
68
+ "webpack-concat-plugin": "^3.0.0",
69
+ "webpack-dev-server": "^3.10.3",
70
+ "webpack-livereload-plugin": "^2.1.1"
71
+ },
72
+ "publishConfig": {
73
+ "access": "public"
74
+ }
75
+ }
@@ -0,0 +1,25 @@
1
+ var fs = require('fs');
2
+ var archiver = require('archiver');
3
+ const { version: version } = require("../package.json");
4
+ var output = fs.createWriteStream('./dist/'+version+'.tar.gz');
5
+ var archive = archiver('tar', {
6
+ gzip: true,
7
+ zlib: { level: 9 } // Sets the compression level.
8
+ });
9
+
10
+ archive.on('error', function(err) {
11
+ throw err;
12
+ });
13
+
14
+ // pipe archive data to the output file
15
+ archive.pipe(output);
16
+
17
+ // append files
18
+ archive.file('./dist/path-kaltura-player.js', {name: 'path-kaltura-player.js'});
19
+ archive.file('./dist/path-kaltura-player.js.map', {name: 'path-kaltura-player.js.map'});
20
+
21
+ // Wait for streams to complete
22
+ archive.finalize();
23
+
24
+ console.log("Done tgz");
25
+
@@ -0,0 +1,22 @@
1
+ const fs = require("fs");
2
+ const versionFile = "./version.ts";
3
+ const cyan = "\x1b[36m%s\x1b[0m";
4
+ const { version: version } = require("../package.json");
5
+
6
+ console.log(
7
+ cyan,
8
+ "setting the version from package.json to version.ts " + version
9
+ );
10
+
11
+ fs.readFile(versionFile, "utf8", function(err, data) {
12
+ if (err) {
13
+ return console.log(err);
14
+ }
15
+
16
+ const splittedFile = data.split('"');
17
+ const newFileContent = splittedFile[0] + '"' + version + '";';
18
+
19
+ fs.writeFile(versionFile, newFileContent, "utf8", function(err) {
20
+ if (err) return console.log(err);
21
+ });
22
+ });
package/scripts/tag.sh ADDED
@@ -0,0 +1,6 @@
1
+ read -p 'enter tag (e.g v0.1.18): ' version;
2
+ echo Trying to push tag $version
3
+ git tag -a $version -m \"$version\"
4
+ git push origin $version
5
+
6
+
@@ -0,0 +1,311 @@
1
+ import { PlayersManager, RaptNode } from "./PlayersManager";
2
+ import { KipClient } from "./KipClient";
3
+ import { createElement } from "./helpers/CreateElement";
4
+ import { Dispatcher, KivEvent } from "./helpers/Dispatcher";
5
+ import { PlayersDomManager } from "./PlayersDomManager";
6
+ import { enable as enableLog, log } from "./helpers/logger";
7
+ import { VERSION } from "../version";
8
+ import convertApiResponce from "./helpers/convertApiResponce";
9
+
10
+ const API_EVENTS = [
11
+ "browser:hidden",
12
+ "browser:open",
13
+ "cue:forward",
14
+ "cue:reverse",
15
+ "hotspot:click",
16
+ "node:enter",
17
+ "node:ended",
18
+ "node:exit",
19
+ "project:load",
20
+ "project:ready",
21
+ "project:start",
22
+ "project:ended",
23
+ "project:unload",
24
+ "player:play",
25
+ "player:pause",
26
+ "player:progress",
27
+ "player:ratechange",
28
+ "player:timeupdate",
29
+ "buffer:prebuffer",
30
+ "buffer:bufferend",
31
+ "buffer:bufferstart",
32
+ "buffer:allbuffered",
33
+ "player:volumechange"
34
+ ];
35
+
36
+ export enum RaptProjectStatus {
37
+ preInitialized = "preInitialized", // before loadMedia
38
+ loading = "loading", // after loadMedia - before data load
39
+ ready = "ready", // ideal. Project is running
40
+ error = "error"
41
+ }
42
+
43
+ class KalturaInteractiveVideo extends Dispatcher {
44
+ private playerManager: PlayersManager;
45
+ private mainDiv: HTMLElement; // TODO 6 should move all executions to use the playerDomManager and remove this property
46
+ private playlistId: string = "";
47
+ private client: KipClient; // Backend Client
48
+ private _data: any; // container to data API
49
+ private legacyCallback: (event: any) => void; // legacy API generic callback func
50
+ private playerDomManager: PlayersDomManager;
51
+ private kalturaInteractiveStatus: RaptProjectStatus =
52
+ RaptProjectStatus.preInitialized;
53
+
54
+ constructor(private config: any, private playerLibrary: any) {
55
+ super();
56
+
57
+ if (config && config.rapt && config.rapt.debug) {
58
+ enableLog();
59
+ log(
60
+ "log",
61
+ "KalturaInteractiveVideo",
62
+ "log enabled by config version " + VERSION
63
+ );
64
+ }
65
+ }
66
+
67
+ private isInitialized = false;
68
+
69
+ // enable log-open externally
70
+ public enableLog() {
71
+ enableLog();
72
+ }
73
+
74
+ // expose version
75
+ public get version() {
76
+ return VERSION;
77
+ }
78
+
79
+ loadMedia(obj: any): void {
80
+ this.kalturaInteractiveStatus = RaptProjectStatus.loading;
81
+ if (!obj || (!obj.entryId && !obj.playlistId)) {
82
+ this.printMessage("Error", "missing rapt project id");
83
+ this.kalturaInteractiveStatus = RaptProjectStatus.error;
84
+ return;
85
+ }
86
+
87
+ if (this.isInitialized) {
88
+ throw new Error(
89
+ 'currently cannot load media twice to the same instance. Please use "setup" method again'
90
+ );
91
+ }
92
+ this.dispatchApi({ type: "project:load", payload: obj.playlistId });
93
+ this.isInitialized = true;
94
+
95
+ this.playerDomManager = new PlayersDomManager(this.config.targetId);
96
+ this.mainDiv = this.playerDomManager.getContainer();
97
+
98
+ let ks: string = this.config.provider.ks ? this.config.provider.ks : "";
99
+ let envUrl = "https://cdnapisec.kaltura.com";
100
+ if (
101
+ this.config.provider &&
102
+ this.config.provider.env &&
103
+ this.config.provider.env.serviceUrl
104
+ ) {
105
+ // player config serviceUrl is expected with "/api_v3" while the app client doesn't
106
+ envUrl = this.config.provider.env.serviceUrl.split("/api_v3")[0];
107
+ }
108
+
109
+ if(this.config.rapt && this.config.rapt.capabilityCheck){
110
+ console.warn("Internal Testing flag of hybrid Rapt entry is enabled in Rapt player");
111
+ }
112
+
113
+ this.client = new KipClient({
114
+ ks: ks,
115
+ partnerId: this.config.provider.partnerId,
116
+ serviceUrl: envUrl,
117
+ capabilityCheck: this.config.rapt.capabilityCheck,
118
+ widgetId: this.config.provider.widgetId
119
+ });
120
+ this.playlistId = obj.playlistId || obj.entryId;
121
+ this.client
122
+ .loadRaptData(this.playlistId)
123
+ .then((graphData) => {
124
+ const { hotspots }: any = graphData;
125
+ if (!hotspots) {
126
+ graphData = convertApiResponce(graphData);
127
+ }
128
+ this.dataLoaded(graphData);
129
+ })
130
+ .catch((err: string) => {
131
+ this.kalturaInteractiveStatus = RaptProjectStatus.error;
132
+ this.printMessage("Error", err);
133
+ this.dispatchApi({ type: "Error" });
134
+ });
135
+ }
136
+
137
+ /**
138
+ * Once the graph-data is loaded - load the 1st media and place the rapt-engine layer
139
+ * @param raptGraphData
140
+ */
141
+ dataLoaded(raptGraphData: object): void {
142
+ const config = Object.assign({}, this.config);
143
+ config.provider.ks = this.client.ks,
144
+ raptGraphData["account"] = { id: this.config.provider.partnerId };
145
+ this._data = raptGraphData;
146
+ this.playerManager = new PlayersManager(
147
+ config,
148
+ this.playerLibrary,
149
+ this.playlistId,
150
+ raptGraphData,
151
+ this.playerDomManager
152
+ );
153
+
154
+ // if we got here - playerManager constructor code went well - update status
155
+ this.kalturaInteractiveStatus = RaptProjectStatus.ready;
156
+
157
+ for (let eventName of API_EVENTS) {
158
+ this.playerManager.addListener(eventName, (event: KivEvent) => {
159
+ this.dispatchApi(event);
160
+ });
161
+ }
162
+ }
163
+ /**
164
+ * Expose API to the wrapping page/app
165
+ * @param event
166
+ * @param data
167
+ */
168
+ dispatchApi(event: KivEvent) {
169
+ //this is a legacy API
170
+ if (this.legacyCallback) {
171
+ let legacyEvent: any = { type: event.type };
172
+ // send the payload only if it exist
173
+ if (event.payload && Object.getOwnPropertyNames(event.payload).length) {
174
+ legacyEvent.payload = event.payload;
175
+ }
176
+ this.legacyCallback(legacyEvent);
177
+ }
178
+
179
+ // expose API, add the current node and
180
+ this.dispatch(event);
181
+ }
182
+
183
+ /**
184
+ * Print a message on the main div, usually used to show error messages to the end-user (E.G. missing rapt data)
185
+ * @param title
186
+ * @param text
187
+ */
188
+ printMessage(title: string, text: string = "") {
189
+ const messageDiv = createElement("div", null, "kiv-message__message");
190
+ const titleDiv = createElement("div", null, "kiv-message__title");
191
+ const bodeDiv = createElement("div", null, "kiv-message__body");
192
+ titleDiv.innerHTML = title;
193
+ bodeDiv.innerHTML = text;
194
+ messageDiv.appendChild(titleDiv);
195
+ messageDiv.appendChild(bodeDiv);
196
+ this.mainDiv.appendChild(messageDiv);
197
+ }
198
+ /**
199
+ * Legacy API support
200
+ */
201
+ public pause() {
202
+ this.playerManager.pause();
203
+ }
204
+
205
+ public play() {
206
+ this.playerManager.play();
207
+ }
208
+
209
+ public seek(n: number) {
210
+ this.playerManager.seek(n);
211
+ }
212
+
213
+ public replay() {
214
+ this.playerManager.execute({
215
+ type: "project:replay"
216
+ });
217
+ }
218
+ public reset() {
219
+ this.playerManager.execute({
220
+ type: "project:reset"
221
+ });
222
+ }
223
+
224
+ public get data(): any {
225
+ return this._data;
226
+ }
227
+
228
+ public get currentTime(): number {
229
+ return this.playerManager.getActiveKalturaPlayer().currentTime;
230
+ }
231
+
232
+ public get duration(): number {
233
+ return this.playerManager.getActiveKalturaPlayer().duration;
234
+ }
235
+
236
+ public get currentNode(): RaptNode {
237
+ return this.playerManager.getActiveKalturaPlayer().node;
238
+ }
239
+
240
+ public get volume(): number {
241
+ return this.playerManager.getActiveKalturaPlayer().player.player.volume;
242
+ }
243
+
244
+ public set volume(n: number) {
245
+ this.playerManager.getActiveKalturaPlayer().player.player.volume = n;
246
+ }
247
+
248
+ public get muted(): number {
249
+ return this.playerManager.getActiveKalturaPlayer().player.player.muted;
250
+ }
251
+
252
+ public get playbackRate(): number {
253
+ return this.playerManager.getActiveKalturaPlayer().playbackRate;
254
+ }
255
+
256
+ public jump(locator: any, autoplay: boolean) {
257
+ this.playerManager.execute({
258
+ type: "project:jump",
259
+ payload: { destination: locator }
260
+ });
261
+ }
262
+
263
+ // Legacy API - kBind support
264
+ public kBind(eventName: string, callback: (event: any) => void) {
265
+ if (eventName === "raptMedia_event") {
266
+ this.legacyCallback = callback;
267
+ } else {
268
+ this.addListener(eventName, callback);
269
+ }
270
+ }
271
+ // legacy API - sendNotification with rapt command data
272
+ public sendNotification(doCommand: string, commandObject: any) {
273
+ this.playerManager.execute(commandObject);
274
+ }
275
+ // direct execute
276
+ public execute(commandObject: any) {
277
+ this.playerManager.execute(commandObject);
278
+ }
279
+
280
+ public evaluate(key: string): any {
281
+ // prepare the info object with legacy data structure
282
+ if (key === "{raptMedia.info}") {
283
+ let dataCopy = Object.assign({}, this._data);
284
+ dataCopy.player = {
285
+ currentNode: this.playerManager.getActiveNode(),
286
+ currentTime: this.playerManager.getActiveKalturaPlayer().currentTime,
287
+ currentVideo: this.playerManager.getActiveNode().entryId
288
+ };
289
+ dataCopy.project = {
290
+ projectId: this.playerManager.raptProjectId
291
+ };
292
+ dataCopy.videos = this._data.nodes.map((item: RaptNode) => {
293
+ let o: any = {};
294
+ o.entryId = item.entryId;
295
+ o.id = item.id;
296
+ o.name = item.name;
297
+ if (o.customData) {
298
+ o.customData = item.customData;
299
+ }
300
+ return o;
301
+ });
302
+ return dataCopy;
303
+ } else if (key === "{raptMedia.status}") {
304
+ return this.kalturaInteractiveStatus;
305
+ } else if (this.data[key]) {
306
+ return this.data[key];
307
+ }
308
+ }
309
+ }
310
+
311
+ export default KalturaInteractiveVideo;
package/src/Kip.scss ADDED
@@ -0,0 +1,270 @@
1
+ .kiv-message__message {
2
+ border-radius: 4px;
3
+ background: #eeeeee;
4
+ }
5
+ .kiv-player.current-playing {
6
+ z-index: 6;
7
+ }
8
+
9
+ .kiv-initiated {
10
+ .playkit-pre-playback-play-overlay {
11
+ display: none;
12
+ }
13
+ }
14
+
15
+ .kiv-player {
16
+ position: absolute;
17
+ &:not(.current-playing) {
18
+ display: none;
19
+ }
20
+ }
21
+
22
+ .kiv-hidden {
23
+ display: none;
24
+ }
25
+
26
+ .kiv-rapt-engine {
27
+ z-index: 7;
28
+ position: absolute;
29
+ html,
30
+ body,
31
+ div,
32
+ span,
33
+ applet,
34
+ object,
35
+ iframe,
36
+ h1,
37
+ h2,
38
+ h3,
39
+ h4,
40
+ h5,
41
+ h6,
42
+ p,
43
+ blockquote,
44
+ pre,
45
+ a,
46
+ abbr,
47
+ acronym,
48
+ address,
49
+ big,
50
+ cite,
51
+ code,
52
+ del,
53
+ dfn,
54
+ em,
55
+ img,
56
+ ins,
57
+ kbd,
58
+ q,
59
+ s,
60
+ samp,
61
+ small,
62
+ strike,
63
+ strong,
64
+ sub,
65
+ sup,
66
+ tt,
67
+ var,
68
+ b,
69
+ u,
70
+ i,
71
+ center,
72
+ dl,
73
+ dt,
74
+ dd,
75
+ ol,
76
+ ul,
77
+ li,
78
+ fieldset,
79
+ form,
80
+ label,
81
+ legend,
82
+ table,
83
+ caption,
84
+ tbody,
85
+ tfoot,
86
+ thead,
87
+ tr,
88
+ th,
89
+ td,
90
+ article,
91
+ aside,
92
+ canvas,
93
+ details,
94
+ embed,
95
+ figure,
96
+ figcaption,
97
+ footer,
98
+ header,
99
+ hgroup,
100
+ menu,
101
+ nav,
102
+ output,
103
+ ruby,
104
+ section,
105
+ summary,
106
+ time,
107
+ mark,
108
+ audio,
109
+ video {
110
+ margin: 0;
111
+ padding: 0;
112
+ border: 0;
113
+ font-size: 100%;
114
+ font: inherit;
115
+ vertical-align: baseline;
116
+ }
117
+ article,
118
+ aside,
119
+ details,
120
+ figcaption,
121
+ figure,
122
+ footer,
123
+ header,
124
+ hgroup,
125
+ menu,
126
+ nav,
127
+ section {
128
+ display: block;
129
+ }
130
+ body {
131
+ line-height: 1;
132
+ }
133
+ ol,
134
+ ul {
135
+ list-style: none;
136
+ }
137
+ blockquote,
138
+ q {
139
+ quotes: none;
140
+ }
141
+ blockquote:before,
142
+ blockquote:after,
143
+ q:before,
144
+ q:after {
145
+ content: "";
146
+ content: none;
147
+ }
148
+ table {
149
+ border-collapse: collapse;
150
+ border-spacing: 0;
151
+ }
152
+ }
153
+
154
+ .kiv-container {
155
+ position: relative;
156
+
157
+ .playkit-player.playkit-size-xs .playkit-left-controls .playkit-control-button-container
158
+ {
159
+ display: inline-block;
160
+ }
161
+
162
+
163
+ &.rapt-switching{
164
+ .playkit-black-cover{
165
+ background-color: transparent;
166
+ }
167
+ .playkit-spinner-container,
168
+ .playkit-poster{
169
+ display: none;
170
+ }
171
+
172
+ }
173
+
174
+ .playkit-player-gui {
175
+ font-family: "courier" !important;
176
+ }
177
+
178
+ .playkit-time-display {
179
+ float: left;
180
+ position: relative;
181
+ left: 0;
182
+ font-family: sans-serif;
183
+ padding: 0;
184
+ margin-right: 6px;
185
+ }
186
+
187
+ .playkit-seek-bar {
188
+ padding: 6px 0;
189
+ cursor: pointer;
190
+ position: relative;
191
+ top: 13px;
192
+ width: calc(100% - 126px);
193
+ left: 45px;
194
+ }
195
+ .hide-fullscreen .playkit-seek-bar {
196
+ width: calc(100% - 96px);
197
+ }
198
+ /* Scrubber width - with audio-tracks/captions */
199
+ .has-extra-tracks .playkit-player .playkit-seek-bar {
200
+ width: calc(100% - 160px) !important;
201
+ }
202
+ .has-extra-tracks .playkit-player .hide-fullscreen .playkit-seek-bar {
203
+ width: calc(100% - 130px) !important;
204
+ }
205
+
206
+ .has-timers {
207
+
208
+ /* Scrubber width (when timers are on) - without audio-tracks/captions */
209
+ .playkit-seek-bar {
210
+ width: calc(100% - 210px) !important;
211
+ }
212
+ /* Scrubber width (when timers are on) - with audio-tracks/captions */
213
+ .has-extra-tracks .playkit-player .playkit-seek-bar {
214
+ width: calc(100% - 246px) !important;
215
+ }
216
+ .has-extra-tracks .playkit-player .hide-fullscreen .playkit-seek-bar{
217
+ width: calc(100% - 216px) !important;
218
+ }
219
+ .playkit-player .hide-fullscreen .playkit-seek-bar{
220
+ width: calc(100% - 186px) !important;
221
+ }
222
+ }
223
+
224
+
225
+ /* Fullscreen exists - reduce the scrubber width by 30px */
226
+ .playkit-seek-bar{
227
+ //padding-right: 30px;
228
+ }
229
+
230
+ /* lack of fullscreen button adds 30px (or in other words removes the default 30) */
231
+ .hide-fullscreen .playkit-seek-bar{
232
+ padding-right: 0px;
233
+ }
234
+
235
+ .playkit-icon-rewind-10 {
236
+ display: none;
237
+ }
238
+
239
+ .playkit-pre-playback-play-button:hover {
240
+ background-color: rgba(0, 0, 0, 0.8);
241
+ box-shadow: 0 0 10px #ffff64;
242
+ text-shadow: 0 0 10px #ffff64;
243
+ }
244
+
245
+ .playkit-player {
246
+ .playkit-bottom-bar {
247
+ padding: 0 8px;
248
+ position: absolute;
249
+ }
250
+ .playkit-control-button,
251
+ .playkit-control-button i {
252
+ width: 20px;
253
+ height: 20px;
254
+ }
255
+
256
+ .playkit-time-display {
257
+ line-height: 22px;
258
+ font-size: 12px;
259
+ }
260
+ .playkit-volume-control-bar {
261
+ bottom: 24px;
262
+ left: -8px;
263
+ }
264
+ }
265
+ }
266
+ .kiv-container,
267
+ .kiv-player {
268
+ width: 100%;
269
+ height: 100%;
270
+ }