@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/index-API.html ADDED
@@ -0,0 +1,307 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8"/>
5
+ <title>Kaltura Interactive Player</title>
6
+ <script
7
+ src="https://code.jquery.com/jquery-3.3.1.min.js"
8
+ integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8="
9
+ crossorigin="anonymous"
10
+ ></script>
11
+ </head>
12
+ <body>
13
+ <!-- relevant for development only! -->
14
+ <!-- 0.36.6 -->
15
+ <!-- <script src="https://qa-apache-php7.dev.kaltura.com/p/6222/embedPlaykitJs/uiconf_id/15219305"></script> -->
16
+ <!-- THIS UICONF HAS GA -->
17
+ <!-- 0.37.3 -->
18
+ <script src="https://qa-apache-php7.dev.kaltura.com/p/6222/embedPlaykitJs/uiconf_id/15220027"></script>
19
+ <!-- 0.39.0 -->
20
+ <!-- <script src="http://cdnapisec.kaltura.com/p/27017/embedPlaykitJs/uiconf_id/43642002"></script> -->
21
+ <script src="dist/path-kaltura-player.js" type="text/javascript"></script>
22
+ <script src="http://localhost:35729/livereload.js"></script>
23
+ <!-- end of relevant for development only! -->
24
+ <!-- 350 x 197 / 260 x 146 / 500 x 281 / 150 x 84 ⬇ ︎-->
25
+ <style>
26
+ #player {
27
+ width: 500px;
28
+ height: 281px;
29
+ }
30
+ </style>
31
+ <h3>test.template.html</h3>
32
+ <h4 id="projDetails"></h4>
33
+ <div id="player"></div>
34
+ <div
35
+ id="logDiv"
36
+ style="width: 450px;height: 100%;position: absolute;left:650px;top:0"
37
+ ></div>
38
+ <script>
39
+ var optionalPlaylists = [
40
+ {
41
+ name: "prefetch API",
42
+ selected: true, ///////////////////////
43
+ id: "0_vd5gg2z6"
44
+ }
45
+ ];
46
+
47
+ var selectedItem;
48
+
49
+ for (var j = 0; j < optionalPlaylists.length; j++) {
50
+ if (optionalPlaylists[j].selected) {
51
+ selectedItem = optionalPlaylists[j];
52
+ }
53
+ }
54
+ var env = {};
55
+ if (selectedItem.isQA) {
56
+ env = {
57
+ serviceUrl: "//qa-apache-php7.dev.kaltura.com/api_v3",
58
+ cdnUrl: "//qa-apache-php7.dev.kaltura.com"
59
+ };
60
+ }
61
+ var pid = 27017; // default
62
+
63
+
64
+ document.getElementById("projDetails").textContent =
65
+ selectedItem.name + " - " + selectedItem.id;
66
+ var config = {
67
+ targetId: "player",
68
+ playback: {
69
+ // autoplay: false,
70
+ preload: "auto"
71
+ },
72
+ provider: {
73
+ // ks : "djJ8NTgwOXw3pr1EYEVjHHuRis2NzxYDzhyn4RnPuMmUhD4GZGmLDEf4oKfJe8xRiSx77VvInhSq8vrHNKc1cMlIitvfyRMpGBKUXNBamu4Rr2-WBGranp5gldiNWQh6l6cKXu0MP3bgj_1fbNVuZSv1t5vEK1dbJdgdSkDmiuTVc9Xhb2folNWucEQYQDSd72z8eIubs10EGzZU1HC28Yl7yofo05OpEXyfpgo_NdFA5D08hTaPmovwUakED2z7gD5AiS6H_gW0wYu95olXSNIPN0em4M4p",
74
+ partnerId: pid,
75
+ uiconfId: "15219991"
76
+ },
77
+ rapt: {
78
+ initialBitrate: 75e4,
79
+ debug: true,
80
+ bufferNextNodes: true,
81
+ bufferTime: 6,
82
+ showScrubber: true,
83
+ showTimers: true,
84
+ showSettings: true
85
+ }
86
+ };
87
+
88
+ var kip = PathKalturaPlayer.setup(config);
89
+
90
+ var allEvents = [
91
+ "hotspot:click",
92
+ "node:enter",
93
+ "node:ended",
94
+ "node:exit",
95
+ "project:load",
96
+ "project:ready",
97
+ "buffer:prebuffer",
98
+ "buffer:bufferend",
99
+ "buffer:bufferstart",
100
+ "buffer:allbuffered",
101
+ "project:start",
102
+ ];
103
+
104
+ for (var i = 0; i < allEvents.length; i++) {
105
+ kip.addListener(allEvents[i], function (event) {
106
+ handleInteractiveEvent(event);
107
+ });
108
+ }
109
+
110
+ kip.loadMedia({playlistId: "0_vd5gg2z6"});
111
+
112
+ // logger - debug mode !
113
+ function handleInteractiveEvent(event) {
114
+ var oneLine = document.createElement("div");
115
+ // mark buffering event in green
116
+ var printStr = event.type;
117
+ var payload = event.payload;
118
+ oneLine.style.cssText = "color: blue";
119
+ switch (event.type) {
120
+
121
+ case "buffer:prebuffer":
122
+ // payload is an array of the next items - first element is the item we are switching to, all other are the
123
+ // next nodes that we will load - by natural order (timeline appearance first, defaultPath later)
124
+ // hard coded - if we are about to load street-food-main - we will push 3 other nodes before the default path
125
+
126
+ //
127
+ if (payload.length) {
128
+ switch (payload[0].name) {
129
+
130
+ // On the 'start' node we want to add dynamically 'Street food' to pre-buffer list. We will push it to the top
131
+ // of the list so it pre-buffers before the 'food' (chocolate video) entry.
132
+ case "Start":
133
+ // find the node of video we want to add
134
+ var streetFoodMainNode = kip.data.nodes.find(node => node.name === "street food main");
135
+ // insert it to the 2nd position of the array
136
+ payload.splice(1, 0, streetFoodMainNode);
137
+ printStr +=
138
+ '<span style="color: #648b24"> [' +
139
+ 'Start - add Street-food ' +
140
+ "]</span>";
141
+ break;
142
+
143
+ case "street food main":
144
+ // Example of finding by node name
145
+ var streetFood1 = kip.data.nodes.find(node => node.name === "street food 1");
146
+ // Example of finding by node id
147
+ var streetFood2 = kip.data.nodes.find(node => node.id === "8a8807ee-acdd-42ae-8e33-b85643b22ca2");
148
+ // Example of finding by node customData
149
+ var streetFood3 = kip.data.nodes.find(node => node.customData === "food3");
150
+ payload.push(streetFood1, streetFood2, streetFood3);
151
+ printStr +=
152
+ '<span style="color: #648b24"> [' +
153
+ 'API adding food 1-3' +
154
+ "]</span>";
155
+
156
+ break;
157
+ case "food main":
158
+ // Example of finding by node name
159
+ var grapesNode = kip.data.nodes.find(node => node.name === "grapes");
160
+ // Example of finding by node id
161
+ var coffeeNode = kip.data.nodes.find(node => node.id === "0f92c236-72a8-4d53-844f-0bf612b1b817");
162
+ // Example of finding by node customData
163
+ var wineNode = kip.data.nodes.find(node => node.customData === "wine");
164
+ payload.push(grapesNode, coffeeNode, wineNode);
165
+ printStr +=
166
+ '<span style="color: #648b24"> [' +
167
+ 'ChocolatChocolatChocolat' +
168
+ "]</span>";
169
+ break;
170
+ case "food default path":
171
+ var food4 = kip.data.nodes.find(node => node.name === "street food 4");
172
+ // insert it to the 2nd position of the array
173
+ payload.push(food4);
174
+ printStr +=
175
+ '<span style="color: #648b24"> [' +
176
+ 'Start - add Street food 4' +
177
+ "]</span>";
178
+ break;
179
+ }
180
+
181
+
182
+ // alter payload object - add more items. This must be a synchronous code
183
+ // we can access the nodes from kip.data.nodes and filter by name, id, custom-data or entryId
184
+ }
185
+ break;
186
+ case "hotspot:click":
187
+ printStr +=
188
+ '<span style="color: #648b24"> [' +
189
+ payload.hotspot.name +
190
+ "]</span>";
191
+ // If there is a custom-data value it will be in payload.hotspot.customData
192
+
193
+ // sample of detecting the hotspot by custom-data:
194
+ if (payload.hotspot.customData && (
195
+ payload.hotspot.customData === "street-food" ||
196
+ payload.hotspot.customData === "food1" ||
197
+ payload.hotspot.customData === "food2" ||
198
+ payload.hotspot.customData === "food3" ||
199
+ payload.hotspot.customData === "food4"
200
+ )) {
201
+ switch (payload.hotspot.customData) {
202
+ case "street-food":
203
+ // jump by node name
204
+ kip.jump({name: 'street food main'});
205
+ break;
206
+ case "food1":
207
+ // jump by node id
208
+ kip.jump({id: '076fdbc8-61cd-462f-934c-ac04ba9de28c'});
209
+ break;
210
+ case "food2":
211
+ // jump by node name
212
+ kip.jump({name: 'food2'});
213
+ break;
214
+ case "food3":
215
+ // jump by node id
216
+ kip.jump({id: '1ca66c6a-51df-4a73-ba64-cd67210d1148'});
217
+ break;
218
+ case "food4":
219
+ // jump by node id
220
+ kip.jump({id: 'ccee5b3a-3436-4cbd-ad88-e68d86ca2431'});
221
+ break;
222
+
223
+ }
224
+ }
225
+ // sample of detecting the hotspot by node name:
226
+ if (
227
+ payload.hotspot.name === "Wine" ||
228
+ payload.hotspot.name === "Grapes" ||
229
+ payload.hotspot.name === "Coffee"
230
+ ) {
231
+ switch (payload.hotspot.name) {
232
+ case "Wine":
233
+ // jump by node id
234
+ kip.jump({id: 'b7258214-659a-41c6-bc28-e3867d52a0fb'});
235
+ break;
236
+ case "Grapes":
237
+ // jump by node name
238
+ kip.jump({name: 'grapes'});
239
+ break;
240
+ case "Coffee":
241
+ // jump by node id
242
+ kip.jump({name: 'coffee'});
243
+ break;
244
+ }
245
+ }
246
+
247
+
248
+ break;
249
+ case "node:enter":
250
+ case "node:ended":
251
+ case "node:exit":
252
+ printStr +=
253
+ '<span style="color: #24468b"> [' +
254
+ payload.node.name +
255
+ "]</span>";
256
+ break;
257
+ case "player:progress":
258
+ printStr +=
259
+ '<span style="color: #8b2136"> [' + payload.progress + "]</span>";
260
+ break;
261
+ case "browser:open":
262
+ printStr +=
263
+ '<span style="color: #648b24"> [' + payload.href + "]</span>";
264
+ break;
265
+ default:
266
+ if (!isEmpty(payload)) {
267
+ printStr +=
268
+ '<span style="color: #9f4e8e"> [' +
269
+ payload.toString() +
270
+ "]</span>";
271
+ }
272
+
273
+ // this is a Rapt event
274
+ }
275
+ oneLine.innerHTML = printStr;
276
+ document.getElementById("logDiv").appendChild(oneLine);
277
+ }
278
+
279
+
280
+ function seekKip(n) {
281
+ kip.seek(n);
282
+ }
283
+
284
+
285
+ // helpers
286
+ function isEmpty(obj) {
287
+ for (var key in obj) {
288
+ if (obj.hasOwnProperty(key)) return false;
289
+ }
290
+ return true;
291
+ }
292
+
293
+ </script>
294
+ <br/>
295
+ <div>
296
+
297
+ <button onclick="seekKip(kip.duration-3)" style="background: #f4cd98">
298
+ Seek to -3sec
299
+ </button>
300
+ <button onclick="seekKip(kip.duration-7)" style="background: #f4Fd98">
301
+ Seek to -7sec
302
+ </button>
303
+
304
+
305
+ </div>
306
+ </body>
307
+ </html>
@@ -0,0 +1,266 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <title>Kaltura Interactive Player </title>
6
+ </head>
7
+ <body>
8
+ <!-- relevant for development only! -->
9
+ <script src="http://cdnapisec.kaltura.com/p/27017/embedPlaykitJs/uiconf_id/43327771"></script>
10
+ <script src="dist/path-kaltura-player.js" type="text/javascript"></script>
11
+ <script src="http://localhost:35729/livereload.js"></script>
12
+ <!-- end of relevant for development only! -->
13
+
14
+
15
+
16
+ <!-- 350 x 197 / 260 x 146 / 500 x 281 / 150 x 84 ⬇ ︎-->
17
+ <style>
18
+ #player {
19
+ width:500px;
20
+ height:281px;
21
+ }
22
+ </style>
23
+ <h3>test.template.html</h3>
24
+ <h4 id="projDetails"></h4>
25
+ <div id="player"></div>
26
+ <div id="logDiv" style="width: 450px;height: 100%;position: absolute;left:650px;top:0"></div>
27
+ <script>
28
+
29
+ var optionalPlaylists = [
30
+ {
31
+ name: "Animals" ,
32
+ id: "1_60y5a49y" ,
33
+ }
34
+ ,
35
+ {
36
+ name: "Complex" ,
37
+ id: "1_51tet0hy",
38
+ } ,
39
+ {
40
+ name: "Empty" ,
41
+ id: "1_sxcxb5e2",
42
+ } ,
43
+ {
44
+ name: "Start 2 Start" ,
45
+ id: "1_guuku0l9",
46
+ } ,
47
+ {
48
+ name: "1 to 2,3,4" ,
49
+ id: "1_4sjm8veb",
50
+ selected: true,
51
+ } ,
52
+ {
53
+ name: "Same-node" ,
54
+ id: "1_4weuna20",
55
+ } ,
56
+ {
57
+ name: "defaultPath" ,
58
+ id: "1_r33krd2s",
59
+ } ,
60
+ {
61
+ name: "self-loop" ,
62
+ id: "1_s0d8kump",
63
+ } ,
64
+ {
65
+ name: "split same" ,
66
+ id: "1_a2m8w1pi",
67
+ } ,
68
+ ];
69
+
70
+ var selectedItem = optionalPlaylists.find(item => item.selected === true);
71
+ document.getElementById("projDetails").textContent = selectedItem.name + " - " + selectedItem.id;
72
+
73
+ var config = {
74
+ session:{
75
+ // ks: "MjE4ZjZhMTY5NzAyMTFmYWE5YjdjYzIwOTZlM2NhODFhY2I1YTNiNnwyNzAxNzsyNzAxNzsxNTM5Njg2ODM5OzI7MTc3O19fQURNSU5fXzI2Njg3OyosZGlzYWJsZWVudGl0bGVtZW50"
76
+ },
77
+ targetId: 'player',
78
+ playback:{
79
+ autoplay:true,
80
+ preload:"auto"
81
+ },
82
+
83
+ provider: {
84
+ partnerId: 27017 // 2413351 - balconet 0_dl86knxb
85
+ },
86
+
87
+ rapt:{
88
+ debug:true,
89
+ bufferNextNodes: true,
90
+ bufferTime: 4
91
+ }
92
+
93
+ };
94
+
95
+ var kip = PathKalturaPlayer.setup(config);
96
+ kip.loadMedia({entryId: selectedItem.id});
97
+ var bufferingEvents = ["buffering","destroying","destroyed","doneBuffering","allBuffered","catchup","allUnbuffered"];
98
+ var apiEvents = [
99
+ "browser:hidden",
100
+ "browser:open",
101
+ "cue:forward",
102
+ "cue:reverse",
103
+ "hotspot:click",
104
+ "node:enter",
105
+ "node:ended",
106
+ "node:exit",
107
+ "project:load",
108
+ "project:ready",
109
+ "project:start",
110
+ "project:unload",
111
+ "project:ended",
112
+ "player:play",
113
+ "player:pause",
114
+ "player:progress",
115
+ "player:ratechange",
116
+ "player:timeupdate",
117
+ "player:volumechange"
118
+ ];
119
+
120
+ var allEvents;
121
+ allEvents = bufferingEvents ;
122
+ // apiEvents.concat(bufferingEvents);
123
+ // allEvents = apiEvents.concat(bufferingEvents);
124
+
125
+ for (var i = 0 ; i< allEvents.length; i++){
126
+ kip.addListener(allEvents[i] , function (event) {
127
+ logDebugMsg(event);
128
+ });
129
+ }
130
+
131
+ // logger - debug mode !
132
+ function logDebugMsg(event){
133
+ const oneLine = document.createElement("div");
134
+ // mark buffering event in green
135
+ var printStr = event.type;
136
+ var payload = event.payload;
137
+
138
+ oneLine.style.cssText = "color: blue";
139
+ switch (event.type) {
140
+ case "player:timeupdate":
141
+ return; // we do not want to print this - it junks the log
142
+ case "cue:forward":
143
+ case "cue:revere":
144
+ printStr+='<span style="color: darkcyan"> ['+payload.cue.customData+']</span>' ;
145
+ break;
146
+ case "hotspot:click":
147
+ printStr+='<span style="color: darkcyan"> ['+payload.hotspot.name+']</span>' ;
148
+ break;
149
+ case "node:enter":
150
+ case "node:ended":
151
+ case "node:exit":
152
+ printStr+='<span style="color: darkcyan"> ['+payload.node.name+']</span>' ;
153
+ break;
154
+ case "player:progress":
155
+ printStr+='<span style="color: darkcyan"> ['+payload.progress+']</span>' ;
156
+ break;
157
+ case "browser:open":
158
+ printStr+='<span style="color: darkcyan"> ['+payload.href+']</span>' ;
159
+ break;
160
+ default:
161
+ if(!isEmpty(payload)){
162
+ printStr+='<span style="color: #9f4e8e"> ['+payload.toString()+']</span>' ;
163
+ }
164
+
165
+
166
+ // this is a Rapt event
167
+ }
168
+ oneLine.innerHTML = printStr;
169
+ document.getElementById("logDiv").appendChild(oneLine);
170
+ }
171
+
172
+ var playKip = function(){
173
+ kip.play();
174
+ }
175
+ function pauseKip(){
176
+ kip.pause();
177
+ }
178
+ function replayKip(){
179
+ kip.replay();
180
+ }
181
+ function resetKip(){
182
+ kip.reset();
183
+ }
184
+ function jumpToNodeKip(o){
185
+ kip.jump(o);
186
+ }
187
+ function seekKip(n){
188
+ kip.seek(n)
189
+ }
190
+ function getNodes() {
191
+ console.table(kip.data.nodes);
192
+ }
193
+ function getMetadata(){
194
+ console.table(kip.metadata.account);
195
+ }
196
+ function currentTime(){
197
+ console.log(kip.currentTime);
198
+ }
199
+ function duration(){
200
+ console.log(kip.duration);
201
+ }
202
+ function currentNode(){
203
+ console.log(kip.currentNode);
204
+ }
205
+ function currentVolume(){
206
+ console.log(kip.volume); // player bug - initial value ?
207
+ }
208
+ function setVolume(n){
209
+ kip.volume = n;
210
+ }
211
+ function muted(){
212
+ console.log(kip.muted); // player bug
213
+ }
214
+ function playbackRate(){
215
+ console.log(kip.playbackRate); // player bug
216
+ }
217
+
218
+ // helpers
219
+ function isEmpty(obj) {
220
+ for(var key in obj) {
221
+ if(obj.hasOwnProperty(key))
222
+ return false;
223
+ }
224
+ return true;
225
+ }
226
+
227
+ </script>
228
+ <br/>
229
+ <div>
230
+ <button onclick="playKip()">play</button>
231
+ <button onclick="pauseKip()">pause</button>
232
+ <button onclick="replayKip()">replay</button>
233
+ <button onclick="resetKip()">reset</button>
234
+ <button onclick="seekKip(5)">Seek to 5</button>
235
+ <button onclick="seekKip(15)">Seek to 15</button>
236
+ <button onclick="seekKip(kip.duration-3)" style="background: #f4cd98">Seek to -3sec</button>
237
+ <br/>
238
+ <br/>
239
+ <button onclick="jumpToNodeKip({id:'7354fd9b-6401-4c10-b261-99b4d183d07e'})">JumpToNode {id:'7354fd9b-6401-4c10-b261-99b4d183d07e'}</button>
240
+ <button onclick="jumpToNodeKip({name:'Start'})">JumpToNode {name:'Start'}</button>
241
+ <br/>
242
+ <button onclick="jumpToNodeKip({ref:'1_4f9mue48'})">JumpToNode {ref:'1_4f9mue48'}</button>
243
+ <!--<button onclick="jumpToNodeKip({ref:'1_4f9mue48'})">JumpToNode {xref:'1_4f9mue48'}</button>-->
244
+ <br/>
245
+ <br/>
246
+ <button onclick="getNodes()">player.data.nodes</button>
247
+ <button onclick="getMetadata()">player.metadata.account</button>
248
+ <br/>
249
+ <br/>
250
+ <button onclick="currentTime()">player.currentTime</button>
251
+ <button onclick="duration()">player.duration</button>
252
+ <button onclick="currentNode()">player.currentNode</button>
253
+ <button onclick="currentNode()">player.currentNode</button>
254
+ <br>
255
+ <br>
256
+ <button onclick="currentVolume()">player.volume</button>
257
+ <button onclick="setVolume(0.5)">player.volume = 0.5</button>
258
+ <button onclick="setVolume(1)">player.volume = 1</button>
259
+ <button onclick="setVolume(0)">player.volume = 0</button>
260
+ <button onclick="muted()">player.muted</button>
261
+
262
+ <br>
263
+ <button onclick="playbackRate()">player.playbackRate</button>
264
+ </div>
265
+ </body>
266
+ </html>