ovenplayer 0.10.39 → 0.10.40

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ovenplayer",
3
- "version": "0.10.39",
3
+ "version": "0.10.40",
4
4
  "description": "OvenPlayer is Open-Source HTML5 Player. OvenPlayer supports WebRTC Signaling from OvenMediaEngine for Sub-Second Latency Streaming.",
5
5
  "main": "dist/ovenplayer.js",
6
6
  "scripts": {
@@ -1,4 +1,5 @@
1
1
  import _ from "utils/underscore";
2
+ import deepMerge from "utils/deepMerge";
2
3
 
3
4
  import {
4
5
  CONTENT_TIME_MODE_CHANGED, SYSTEM_TEXT
@@ -82,12 +83,13 @@ const Configurator = function (options, provider) {
82
83
  let currentSystemText = _.findWhere(SYSTEM_TEXT, { "lang": userCustumSystemText[i].lang });
83
84
  if (currentSystemText) {
84
85
  //validate & update
85
- Object.assign(currentSystemText, userCustumSystemText[i]);
86
+ deepMerge(currentSystemText, userCustumSystemText[i]);
86
87
  } else {
87
88
  //create
88
89
  currentSystemText = _.findWhere(SYSTEM_TEXT, { "lang": "en" });
89
90
  currentSystemText.lang = userCustumSystemText[i].lang;
90
- SYSTEM_TEXT.push(Object.assign(userCustumSystemText[i], currentSystemText));
91
+ const newMerged = deepMerge({}, currentSystemText, userCustumSystemText[i]);
92
+ SYSTEM_TEXT.push(newMerged);
91
93
  }
92
94
  }
93
95
  }
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Performs a deep merge of the `source` object's properties into the `target` object.
3
+ * For nested objects, the function recurses; otherwise it directly overwrites values.
4
+ *
5
+ * @param {Object} target - The object to which properties are merged.
6
+ * @param {Object} source - The object containing properties to be copied.
7
+ * @returns {Object} The modified `target` object reference.
8
+ *
9
+ * @example
10
+ * const objA = {
11
+ * a: 1,
12
+ * b: { x: 10, y: 20 }
13
+ * };
14
+ * const objB = {
15
+ * b: { y: 999, z: 50 },
16
+ * c: 3
17
+ * };
18
+ *
19
+ * deepMerge(objA, objB);
20
+ * Result: objA = {
21
+ * a: 1,
22
+ * b: { x: 10, y: 999, z: 50 },
23
+ * c: 3
24
+ * }
25
+ */
26
+ export default function deepMerge(target, source) {
27
+ for (let key in source) {
28
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
29
+ if (
30
+ typeof source[key] === "object" &&
31
+ source[key] !== null &&
32
+ typeof target[key] === "object" &&
33
+ target[key] !== null
34
+ ) {
35
+ deepMerge(target[key], source[key]);
36
+ } else {
37
+ target[key] = source[key];
38
+ }
39
+ }
40
+ }
41
+ return target;
42
+ }
@@ -19,6 +19,8 @@ const TimeDisplay = function ($container, api, data) {
19
19
  let hlsLive = false;
20
20
  let nativeHlsLive = false;
21
21
 
22
+ let currVodPosition = 0;
23
+
22
24
  function convertHumanizeTime(time) {
23
25
  return naturalHms(time);
24
26
  }
@@ -29,6 +31,7 @@ const TimeDisplay = function ($container, api, data) {
29
31
  }
30
32
 
31
33
  const onRendered = function ($current, template) {
34
+ currVodPosition = 0;
32
35
  let isTimecode = api.isTimecodeMode();
33
36
  $position = $current.find(".op-time-current");
34
37
  $duration = $current.find(".op-time-duration");
@@ -48,19 +51,25 @@ const TimeDisplay = function ($container, api, data) {
48
51
  if (isTimecode) {
49
52
  $duration.text(convertHumanizeTime(data.duration));
50
53
  } else {
54
+ $position.text(0);
51
55
  $duration.text(Math.round(data.duration * api.getFramerate()) + " (" + api.getFramerate() + "fps)");
52
56
  }
53
57
 
54
58
  api.on(CONTENT_TIME_MODE_CHANGED, function (isTimecodeMode) {
55
59
  isTimecode = isTimecodeMode;
56
60
  if (isTimecode) {
61
+ $position.text(convertHumanizeTime(currVodPosition));
57
62
  $duration.text(convertHumanizeTime(data.duration));
58
63
  } else {
64
+ $position.text(Math.round(currVodPosition * api.getFramerate()));
59
65
  $duration.text(Math.round(data.duration * api.getFramerate()) + " (" + api.getFramerate() + "fps)");
60
66
  }
61
67
  }, template);
62
68
 
63
69
  api.on(CONTENT_TIME, function (data) {
70
+
71
+ currVodPosition = data.position;
72
+
64
73
  if (isTimecode) {
65
74
  $position.text(convertHumanizeTime(data.position));
66
75
  } else {
@@ -409,10 +409,11 @@ const View = function($container){
409
409
  }
410
410
  }
411
411
 
412
- api.showControls = function (show) {
412
+ api.showControls = function (show, keepOpen) {
413
413
  if (show) {
414
414
  $playerRoot.removeClass("op-no-controls");
415
- setHide(false, true);
415
+ let autoHide = !keepOpen
416
+ setHide(false, autoHide);
416
417
  } else {
417
418
  $playerRoot.addClass("op-no-controls");
418
419
  }