@mediakind/mkplayer 1.0.10 → 1.0.11

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/src/MKPlayer.ts CHANGED
@@ -24,7 +24,7 @@ export class MKPlayer {
24
24
  */
25
25
  constructor(containerElement: HTMLElement, mkPlayerConfiguration: MKPlayerConfiguration) {
26
26
  let playerConfig: PlayerConfig = {
27
- key: '84dc4716-55f9-43fa-ae8e-6fa334c5189b',
27
+ key: mkPlayerConfiguration.key,
28
28
  playback: {
29
29
  autoplay: mkPlayerConfiguration.autoplay,
30
30
  muted: mkPlayerConfiguration.muted,
@@ -56,18 +56,42 @@ export class MKPlayer {
56
56
  },
57
57
  };
58
58
 
59
- let player = new Player(containerElement, playerConfig);
59
+ if (mkPlayerConfiguration.ui === false) {
60
+ playerConfig.ui = false;
61
+ }
60
62
 
61
- if (mkPlayerConfiguration.smallScreen) {
62
- UIFactory.buildDefaultSmallScreenUI(player);
63
- } else {
64
- UIFactory.buildDefaultUI(player);
63
+ if (mkPlayerConfiguration.targetLatency > 0) {
64
+ playerConfig.live = {
65
+ lowLatency: {
66
+ targetLatency: mkPlayerConfiguration.targetLatency,
67
+ catchup: {
68
+ playbackRateThreshold: 0.075,
69
+ seekThreshold: 12,
70
+ playbackRate: 1.2,
71
+ },
72
+ fallback: {
73
+ playbackRateThreshold: 0.075,
74
+ seekThreshold: 12,
75
+ playbackRate: 0.8,
76
+ },
77
+ },
78
+ };
79
+ }
80
+
81
+ let player = new Player(containerElement, playerConfig);
82
+ if (mkPlayerConfiguration.ui !== false) {
83
+ if (mkPlayerConfiguration.smallScreen) {
84
+ UIFactory.buildDefaultSmallScreenUI(player);
85
+ } else {
86
+ UIFactory.buildDefaultUI(player);
87
+ }
65
88
  }
66
89
 
67
90
  if (mkPlayerConfiguration.debug) {
68
91
  Logger.enable();
69
92
  }
70
93
 
94
+
71
95
  this.player = player;
72
96
 
73
97
  console.log('%c MKPlayer ' + this.version() + ' www.mediakind.com', 'color: blue');
@@ -190,6 +214,22 @@ export class MKPlayer {
190
214
  };
191
215
  }
192
216
 
217
+ /**
218
+ * sets the target latency during live playback
219
+ * @param latency
220
+ */
221
+ setTargetLatency(latency: number) {
222
+ this.player.lowlatency.setTargetLatency(latency);
223
+ }
224
+
225
+ /**
226
+ * sets the target latency during live playback
227
+ * @param latency
228
+ */
229
+ getLatency(): number {
230
+ return this.player.lowlatency.getLatency();
231
+ }
232
+
193
233
  /**
194
234
  * mutes the player
195
235
  */
@@ -197,6 +237,13 @@ export class MKPlayer {
197
237
  this.player.mute();
198
238
  }
199
239
 
240
+ /**
241
+ * gets the current playback speed
242
+ */
243
+ playbackSpeed(): number {
244
+ return this.player.getPlaybackSpeed();
245
+ }
246
+
200
247
  /**
201
248
  * unmute the player
202
249
  */
@@ -282,6 +329,12 @@ export class MKPlayer {
282
329
  case MKEvent.Unloaded:
283
330
  playerEventType = PlayerEvent.SourceUnloaded;
284
331
  break;
332
+ case MKEvent.Metadata:
333
+ playerEventType = PlayerEvent.Metadata;
334
+ break;
335
+ case MKEvent.MetadataParsed:
336
+ playerEventType = PlayerEvent.MetadataParsed;
337
+ break;
285
338
  }
286
339
 
287
340
  return playerEventType;
@@ -21,4 +21,19 @@ export interface MKPlayerConfiguration {
21
21
  * Boolean indicating if the player should load the small screen ui
22
22
  */
23
23
  smallScreen: boolean;
24
+
25
+ /**
26
+ * Boolean to enable / disable ui
27
+ */
28
+ ui: boolean;
29
+
30
+ /**
31
+ * number of seconds the player attempts to stay behind the live point
32
+ */
33
+ targetLatency: number;
34
+
35
+ /**
36
+ * license key for the video player
37
+ */
38
+ key: string;
24
39
  }
@@ -13,4 +13,6 @@ export enum MKEvent {
13
13
  QualityChanged = 'qualitychanged',
14
14
  SegmentPlayback = 'segmentplayback',
15
15
  Unloaded = 'unloaded',
16
+ MetadataParsed = 'metadataparsed',
17
+ Metadata = 'metadata',
16
18
  }