@mediakind/mkplayer 1.0.7

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.
Files changed (45) hide show
  1. package/README.md +125 -0
  2. package/azure-pipelines.yml +34 -0
  3. package/dist/BufferLevel.d.ts +4 -0
  4. package/dist/Logger.d.ts +9 -0
  5. package/dist/MKPlayer.d.ts +26 -0
  6. package/dist/MKPlayerConfiguration.d.ts +6 -0
  7. package/dist/MKStream.d.ts +16 -0
  8. package/dist/SubtitleTrack.d.ts +4 -0
  9. package/dist/events/MKEvent.d.ts +13 -0
  10. package/dist/events/MKPlayerEventCallback.d.ts +4 -0
  11. package/dist/index.d.ts +4 -0
  12. package/dist/mkplayer.js +1 -0
  13. package/doc/assets/css/main.css +1 -0
  14. package/doc/assets/images/icons.png +0 -0
  15. package/doc/assets/images/icons@2x.png +0 -0
  16. package/doc/assets/images/widgets.png +0 -0
  17. package/doc/assets/images/widgets@2x.png +0 -0
  18. package/doc/assets/js/main.js +51 -0
  19. package/doc/assets/js/search.json +1 -0
  20. package/doc/classes/mkplayer.html +588 -0
  21. package/doc/enums/mkevent.html +303 -0
  22. package/doc/globals.html +146 -0
  23. package/doc/index.html +309 -0
  24. package/doc/interfaces/bufferlevel.html +140 -0
  25. package/doc/interfaces/mkplayerconfiguration.html +233 -0
  26. package/doc/interfaces/mkplayereventcallback.html +167 -0
  27. package/doc/interfaces/subtitletrack.html +195 -0
  28. package/favicon.ico +0 -0
  29. package/index.html +430 -0
  30. package/mk_logo.png +0 -0
  31. package/mkplayer-ui.min.css +2 -0
  32. package/mkplayer.zip +0 -0
  33. package/package.json +51 -0
  34. package/src/BufferLevel.ts +7 -0
  35. package/src/Logger.ts +51 -0
  36. package/src/MKPlayer.ts +289 -0
  37. package/src/MKPlayerConfiguration.ts +24 -0
  38. package/src/MKStream.ts +74 -0
  39. package/src/SubtitleTrack.ts +14 -0
  40. package/src/events/MKEvent.ts +16 -0
  41. package/src/events/MKPlayerEventCallback.ts +8 -0
  42. package/src/index.ts +4 -0
  43. package/tsconfig.json +20 -0
  44. package/tslint.json +72 -0
  45. package/typedoc.json +11 -0
package/index.html ADDED
@@ -0,0 +1,430 @@
1
+ <!DOCTYPE html>
2
+ <html lang='en'>
3
+ <head>
4
+ <title>MKPlayer 1.0.7</title>
5
+ <meta charset='UTF-8'/>
6
+ <meta http-equiv='X-UA-Compatible' content='IE=edge,chrome=1'>
7
+ <meta name='viewport' content='width=device-width, initial-scale=1.0'>
8
+ <link rel='stylesheet' href='https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css' integrity='sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm'
9
+ crossorigin='anonymous'>
10
+ <script
11
+ src='https://code.jquery.com/jquery-3.4.1.min.js'
12
+ integrity='sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo='
13
+ crossorigin='anonymous'></script>
14
+ <script src='https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js'></script>
15
+ <script src='https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js' integrity='sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl'
16
+ crossorigin='anonymous'></script>
17
+ <script type='text/javascript' src='./dist/mkplayer.js'></script>
18
+ <link rel='stylesheet' href='./mkplayer-ui.min.css'>
19
+ <style>
20
+ .player-wrapper {
21
+ margin: 20px auto;
22
+ box-shadow: 0 0 30px rgba(0, 0, 0, 0.7);
23
+ }
24
+
25
+ .meta-info {
26
+ text-align: center;
27
+ }
28
+
29
+ .row {
30
+ margin: 20px 0;
31
+ }
32
+
33
+ .content-selection {
34
+ display: flex;
35
+ flex-wrap: wrap;
36
+ flex-direction: row;
37
+ justify-content: center;
38
+ align-items: center;
39
+ }
40
+
41
+ .content-selection > label {
42
+ margin: 5px;
43
+ }
44
+ </style>
45
+ </head>
46
+ <body>
47
+ <div class='container'>
48
+ <div class='meta-info'>
49
+ <div class='row'>
50
+ <div class="col-10">
51
+ <div class="float-left">
52
+ <a href="doc/index.html">Check out our docs!</a>
53
+ </div>
54
+ </div>
55
+ <div class="col-2">
56
+ <div class="float-right"><a href="https://www.w3schools.com"><img src="mk_logo.png" alt="Girl in a jacket" width="50" height="30" href="www.mediakind.com"></a>
57
+ </div>
58
+ </div>
59
+ </div>
60
+ <div class='row'>
61
+ <div class='col'>
62
+ <div class='input-group mb-3'>
63
+ <input id='steam-stream-url' type='text' class='form-control' placeholder='Custom primaryUrl' aria-label='Custom primaryUrl' value="">
64
+ <input id='steam-stream-secondary-url' type='text' class='form-control' placeholder='Custom secondaryUrl' aria-label='Custom secondaryUrl' value="">
65
+ <input id='subtitle-url' type='text' class='form-control' placeholder='SubtitleTrack url' aria-label='SubtitleTrack url' value="">
66
+ <input id='subtitle-language' type='text' class='form-control' placeholder='SubtitleTrack language' aria-label='SubtitleTrack language' value="">
67
+ <div class='input-group-append'>
68
+ <button id='load-custom-steam' class='btn btn-outline-secondary' type='button'>Load</button>
69
+ <button id='unload-stream' class='btn btn-outline-secondary' type='button'>Unload</button>
70
+ </div>
71
+ <br/>
72
+ </div>
73
+ </div>
74
+ </div>
75
+
76
+ </div>
77
+ <div class='content'>
78
+ <div class='player-wrapper'>
79
+ <div id='player'></div>
80
+ </div>
81
+ </div>
82
+ <div class='row'>
83
+ <div class='col-12'>
84
+ <div class='content-selection btn-group btn-group-toggle' data-toggle='buttons'>
85
+ <label class='btn btn-outline-secondary'>
86
+ <input type='radio' name='options' id='option-vod' autocomplete='off'>HLS VOD
87
+ </label>
88
+ <label class='btn btn-outline-secondary active'>
89
+ <input type='radio' name='options' id='option-live' autocomplete='off' checked>Live
90
+ </label>
91
+ <label class='btn btn-outline-secondary'>
92
+ <input type='radio' name='options' id='option-dash-vod' autocomplete='off'>DASH VOD
93
+ </label>
94
+ <label class='btn btn-outline-secondary'>
95
+ <input type='radio' name='options' id='option-dash-subtitle' autocomplete='off'>DASH Subtitle
96
+ </label>
97
+ <label class='btn btn-outline-secondary'>
98
+ <input type='radio' name='options' id='option-hls-subtitle' autocomplete='off'>HLS Subtitle
99
+ </label>
100
+ <label class='btn btn-outline-secondary'>
101
+ <input type='radio' name='options' id='option-mp4-1' autocomplete='off'>MP4 Source 1
102
+ </label>
103
+ <label class='btn btn-outline-secondary'>
104
+ <input type='radio' name='options' id='option-mp4-2' autocomplete='off'>MP4 Source 2
105
+ </label>
106
+ <label class='btn btn-outline-secondary'>
107
+ <input type='radio' name='options' id='option-mp4-3' autocomplete='off'>MP4 Source 3
108
+ </label>
109
+ <label class='btn btn-outline-secondary'>
110
+ <input type='radio' name='options' id='option-error' autocomplete='off'>Error Source
111
+ </label>
112
+ </div>
113
+ </div>
114
+ </div>
115
+ <div class='row'>
116
+ <div class='col-12'>
117
+ <div class='content-selection btn-group btn-group-toggle' data-toggle='buttons'>
118
+ <label class='btn btn-outline-secondary'>
119
+ <input type='radio' name='options' id='option-destroy' autocomplete='off'>destroy()
120
+ </label>
121
+ </div>
122
+ </div>
123
+ </div>
124
+
125
+ <div class='row'>
126
+ <div class='col-12'>
127
+ <p>Video Buffer </p>
128
+ <div class='progress'>
129
+ <div class='progress-bar progress-bar-striped progress-bar-animated' role='progressbar' aria-valuenow='0' aria-valuemin='0' aria-valuemax='100' style='width: 0'
130
+ id='videoBuffer'></div>
131
+ </div>
132
+ </div>
133
+ </div>
134
+ <div class='row'>
135
+ <div class='col-12'>
136
+ <p>Audio Buffer</p>
137
+ <div class='progress'>
138
+ <div class='progress-bar progress-bar-striped progress-bar-animated' role='progressbar' aria-valuenow='0' aria-valuemin='0' aria-valuemax='100' style='width: 0'
139
+ id='audioBuffer'></div>
140
+ </div>
141
+ </div>
142
+ </div>
143
+
144
+ <div class='row'>
145
+ <div class='col-12'>
146
+ <p id='startupTime'>Video Startup Time: unknown</p>
147
+ </div>
148
+ </div>
149
+ <div class='row'>
150
+ <div class='col-12'>
151
+ <p id='playbackBitrate'>Video Playback Bitrate: unknown</p>
152
+ </div>
153
+ </div>
154
+ <div class='row'>
155
+ <div class='col-12'>
156
+ <p id='segmentPlaybackLabel'>Segment: unknown</p>
157
+ </div>
158
+ </div>
159
+ </div>
160
+ <script type='text/javascript'>
161
+ let mkPlayer;
162
+ let vodButton = $('#option-vod').parent();
163
+ let dashVodButton = $('#option-dash-vod').parent();
164
+ let dashSubtitleButton = $('#option-dash-subtitle').parent();
165
+ let hlsSubtitleButton = $('#option-hls-subtitle').parent();
166
+ let mp4Button = $('#option-mp4-1').parent();
167
+ let mp4Button2 = $('#option-mp4-2').parent();
168
+ let mp4Button3 = $('#option-mp4-3').parent();
169
+ let liveButton = $('#option-live').parent();
170
+ let errorButton = $('#option-error').parent();
171
+ let destroyButton = $('#option-destroy').parent();
172
+ let customStreamButton = $('#load-custom-steam');
173
+ let unloadStream = $('#unload-stream');
174
+ let loadTime;
175
+ let startupTimeCalculated = false;
176
+
177
+ function deselectCustomLoadButton() {
178
+ $(customStreamButton).removeClass('active');
179
+ }
180
+
181
+ function load(source) {
182
+ loadTime = Date.now();
183
+ startupTimeCalculated = false;
184
+ mkPlayer.load(source).then(function() {
185
+ console.log('MKPlayer Example Page Loaded Source Successfully');
186
+ }, function(reason) {
187
+ console.error('MKPlayer Example Page - Error loading MKPlayer Source');
188
+ console.error(reason);
189
+ });
190
+ }
191
+
192
+ vodButton.on('click', function() {
193
+ vodButton.button('toggle');
194
+ deselectCustomLoadButton();
195
+ load(vodSource);
196
+ });
197
+
198
+ destroyButton.on('click', function() {
199
+ mkPlayer.unload();
200
+ mkPlayer.destroy();
201
+ });
202
+
203
+ dashVodButton.on('click', function() {
204
+ dashVodButton.button('toggle');
205
+ deselectCustomLoadButton();
206
+ load(dashVodSource);
207
+ });
208
+
209
+ hlsSubtitleButton.on('click', function() {
210
+ hlsSubtitleButton.button('toggle');
211
+ deselectCustomLoadButton();
212
+ load(hlsSubtitleSource);
213
+ });
214
+
215
+ dashSubtitleButton.on('click', function() {
216
+ dashSubtitleButton.button('toggle');
217
+ deselectCustomLoadButton();
218
+ load(dashSubtitleSource);
219
+ });
220
+
221
+ errorButton.on('click', function() {
222
+ errorButton.button('toggle');
223
+ deselectCustomLoadButton();
224
+ load(errorSource);
225
+ });
226
+
227
+ mp4Button.on('click', function() {
228
+ mp4Button.button('toggle');
229
+ deselectCustomLoadButton();
230
+ load(mp4Source);
231
+ });
232
+
233
+ mp4Button2.on('click', function() {
234
+ mp4Button2.button('toggle');
235
+ deselectCustomLoadButton();
236
+ load(mp4Source2);
237
+ });
238
+
239
+ mp4Button3.on('click', function() {
240
+ mp4Button3.button('toggle');
241
+ deselectCustomLoadButton();
242
+ load(mp4Source3);
243
+ });
244
+
245
+ liveButton.on('click', function() {
246
+ liveButton.button('toggle');
247
+ deselectCustomLoadButton();
248
+
249
+ mkPlayer.unload();
250
+ load(liveSource);
251
+ });
252
+
253
+ customStreamButton.on('click', function() {
254
+ // remove active button of group
255
+ $($('.btn-group-toggle .active')[0]).removeClass('active');
256
+ let customSource = {
257
+ primaryUrl: $('#steam-stream-url').val(),
258
+ secondaryUrl: $('#steam-stream-secondary-url').val(),
259
+ cdnFailoverPercent: 10,
260
+ assetIdentifier: 'Custom Source',
261
+ };
262
+
263
+ if($('#subtitle-url').val() && $('#subtitle-language').val()) {
264
+ customSource.subtitleTracks = [{
265
+ url: $('#subtitle-url').val(),
266
+ language: $('#subtitle-language').val(),
267
+ }]
268
+ }
269
+
270
+ mkPlayer.unload();
271
+ load(customSource);
272
+ });
273
+
274
+ unloadStream.on('click', function() {
275
+
276
+ $($('.btn-group-toggle .active')[0]).removeClass('active');
277
+
278
+ // remove active button of group
279
+ mkPlayer.unload();
280
+ });
281
+
282
+ let liveSource = {
283
+ primaryUrl: "https://live-mkmsctacdn.azureedge.net/cmaf/TESTCES1/index.m3u8",
284
+ cdnFailoverPercent: 10,
285
+ assetIdentifier: 'DASH Live',
286
+ };
287
+
288
+ let dashSubtitleSource = {
289
+ primaryUrl: "https://bitmovin-a.akamaihd.net/content/sintel/sintel.mpd",
290
+ subtitleTracks: [{
291
+ url: 'https://bitdash-a.akamaihd.net/content/sintel/subtitles/subtitles_en.vtt',
292
+ language: 'aa',
293
+ }],
294
+ assetIdentifier: 'DASH Subtitle',
295
+ poster: 'https://bitmovin-a.akamaihd.net/content/sintel/poster.png'
296
+ };
297
+
298
+ let dashVodSource = {
299
+ primaryUrl: "https://mk-orionsedge.azureedge.net/d2ct1/dash/tenant1_ASMIK_ASMI0000000000000920/manifest.mpd",
300
+ cdnFailoverPercent: 0,
301
+ assetIdentifier: 'DASH VOD',
302
+ subtitleTracks: [{
303
+ url: 'https://bitdash-a.akamaihd.net/content/sintel/subtitles/subtitles_en.vtt',
304
+ language: 'ms',
305
+ }],
306
+ }
307
+
308
+ let hlsSubtitleSource = {
309
+ primaryUrl: 'https://mk-orionsedge.azureedge.net/test/hls/tos/index.m3u8',
310
+ cdnFailoverPercent: 0,
311
+ assetIdentifier: 'HLS Subtitle'
312
+ }
313
+
314
+ var vodSource = {
315
+ primaryUrl: "https://mk-orionsedge.azureedge.net/d2ct1/hls/tenant1_ASMIK_ASMI0000000000000920/index.m3u8",
316
+ assetIdentifier: 'HLS Vod',
317
+ cdnFailoverPercent: 10,
318
+ subtitleTracks: [{
319
+ url: 'https://bitdash-a.akamaihd.net/content/sintel/subtitles/subtitles_en.vtt',
320
+ language: 'ms',
321
+ }],
322
+ };
323
+
324
+ var mp4Source = {
325
+ primaryUrl: "https://mkplayer.z13.web.core.windows.net/vectors/product.mp4",
326
+ assetIdentifier: 'MP4 Source 1',
327
+ }
328
+
329
+ var mp4Source2 = {
330
+ primaryUrl: "https://mkplayer.z13.web.core.windows.net/vectors/mys_video.mp4",
331
+ assetIdentifier: 'MP4 Source 2',
332
+ }
333
+
334
+ var mp4Source3 = {
335
+ primaryUrl: "https://mediusproduction.blob.core.windows.net/video-28731/Build2020Satya.mp4?sv=2018-03-28&sr=c&sig=KyUgEjjChf7RD5SzHisGTn3%2BXkof%2FHYSBMWSaj7EHCs%3D&se=2025-05-19T17%3A16%3A57Z&sp=r",
336
+ assetIdentifier: 'MP4 Source 3',
337
+ subtitleTracks: [
338
+ {
339
+ url: 'https://mediusproduction.blob.core.windows.net/video-28731/Caption_fi-FI.vtt?sv=2018-03-28&amp;sr=c&amp;sig=jsW7SssIhDY9ESoLoDjYgjmCSX1LyRVcM2AVa%2FPIZN8%3D&se=2025-05-22T14%3A22%3A12Z&sp=r',
340
+ language: 'fi',
341
+ },
342
+ {
343
+ url: 'https://mediusprodstatic.studios.ms/video-28731/Caption_ar-EG.vtt?sv=2018-03-28&sr=c&sig=qFHd87nMFTZWXNkDIEcq4656fFH6Zb%2Fd40q4zaVSOJA%3D&se=2025-05-26T15%3A52%3A20Z&sp=r',
344
+ language: 'ms',
345
+ }
346
+ ],
347
+ }
348
+
349
+ let errorSource = {
350
+ primaryUrl: "https://bitdash-a.akamaihd.net/content/sintel/hls/plaasdfasdfadfylist.m3u8",
351
+ assetIdentifier: 'Error Asset',
352
+ cdnFailoverPercent: 10,
353
+ };
354
+
355
+ let mkPlayerConfiguration = {
356
+ debug: true,
357
+ autoplay: true,
358
+ muted: true,
359
+ smallScreen: false,
360
+ };
361
+
362
+ let playerContainer = document.getElementById('player');
363
+ mkPlayer = new mkplayer.MKPlayer(playerContainer, mkPlayerConfiguration);
364
+
365
+ mkPlayer.on('error', function(event) {
366
+ console.error('[MKPlayer] error: %d - %s', event.code, event.name);
367
+ })
368
+
369
+ mkPlayer.on('warning', function(event) {
370
+ console.error('[MKPlayer] warning: %d - %s', event.code, event.name);
371
+ })
372
+
373
+ mkPlayer.on('ready', function(event) {
374
+ console.info('[MKPlayer] ready ' + event.timestamp);
375
+ })
376
+
377
+ mkPlayer.on('timechanged', function(event) {
378
+ var videoBufferLevel = Math.round(getVideoBufferLevel() * 100) / 100;
379
+ $('#videoBuffer').css('width', videoBufferLevel + '%').attr('aria-valuenow', videoBufferLevel);
380
+ $('#videoBuffer').text(videoBufferLevel)
381
+
382
+ var audioBufferLevel = Math.round(getAudioBufferLevel() * 100) / 100;
383
+ $('#audioBuffer').css('width', audioBufferLevel + '%').attr('aria-valuenow', audioBufferLevel);
384
+ $('#audioBuffer').text(audioBufferLevel)
385
+ })
386
+
387
+ mkPlayer.on('playing', function(event) {
388
+ if (!startupTimeCalculated) {
389
+ const startupTime = new Date(Date.now() - loadTime);
390
+ $('#startupTime').text('Video Startup Time: ' + startupTime.getSeconds() + "." + startupTime.getMilliseconds());
391
+ startupTimeCalculated = true
392
+ }
393
+ })
394
+
395
+ mkPlayer.on('paused', function(event) {
396
+ console.info('[MKPlayer] paused' + JSON.stringify(event));
397
+ })
398
+
399
+ mkPlayer.on('playbackfinished', (event) => {
400
+ console.info('[MKPlayer] playbackfinished' + JSON.stringify(event));
401
+ })
402
+
403
+ mkPlayer.on('segmentplayback', function(event) {
404
+ if (event.mimeType === 'video/mp4') {
405
+ let segmentUrl = event.url
406
+ let fileNameIndex = segmentUrl.lastIndexOf("/") + 1;
407
+ var filename = segmentUrl.substr(fileNameIndex);
408
+ $('#segmentPlaybackLabel').text('[MKPlayer] Segment: url=' + filename + ' currentTime=' + mkPlayer.getCurrentTime() + ' time=' + event.playbackTime)
409
+ previousSegmentPlaybackTime = event.playbackTime;
410
+ }
411
+ })
412
+
413
+ mkPlayer.on('qualitychanged', function(event) {
414
+ currentPlayingBitrate = event.targetQuality.bitrate
415
+ $('#playbackBitrate').text('Video Playback Quality: ' + currentPlayingBitrate)
416
+ });
417
+
418
+ var getVideoBufferLevel = function() {
419
+ return mkPlayer.getBufferLevels().video
420
+ }
421
+
422
+ var getAudioBufferLevel = function() {
423
+ return mkPlayer.getBufferLevels().audio
424
+ }
425
+
426
+ load(liveSource)
427
+
428
+ </script>
429
+ </body>
430
+ </html>
package/mk_logo.png ADDED
Binary file