@desynova-digital/player 4.1.6 → 4.1.8

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.
@@ -61,7 +61,7 @@ var VideoTitle = _styledComponents["default"].button(_templateObject2 || (_templ
61
61
  var isShowPageAvailable = _ref.isShowPageAvailable;
62
62
  return isShowPageAvailable ? 'pointer' : 'default';
63
63
  });
64
- var IconButton = (0, _styledComponents["default"])(_components.Button)(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n background: ", ";\n border-radius: 8px;\n padding: 4px;\n border: 1px solid ", ";\n transition: all 0.2s ease;\n\n /* Icon color */\n svg path {\n fill: ", " !important;\n }\n\n &:hover {\n background: ", ";\n border-color: ", ";\n\n svg path {\n fill: ", " !important;\n }\n }\n\n &:active {\n background: ", ";\n }\n"])), function (_ref2) {
64
+ var IconButton = (0, _styledComponents["default"])(_components.Button)(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n background: ", ";\n border-radius: 8px;\n padding: 4px;\n border: 1px solid\n ", ";\n transition: all 0.2s ease;\n\n /* Icon color */\n svg path {\n fill: ", " !important;\n }\n\n &:hover {\n background: ", ";\n border-color: ", ";\n\n svg path {\n fill: ", " !important;\n }\n }\n\n &:active {\n background: ", ";\n }\n"])), function (_ref2) {
65
65
  var isRightMenuVisible = _ref2.isRightMenuVisible;
66
66
  return isRightMenuVisible ? '#ffffff' : '#0bbec5';
67
67
  }, function (_ref3) {
@@ -262,7 +262,7 @@ var PlayerHeader = exports["default"] = /*#__PURE__*/function (_Component) {
262
262
  className: "versions-dropdown-block"
263
263
  }, /*#__PURE__*/_react["default"].createElement("p", {
264
264
  className: "active-version"
265
- }, "".concat(activeVersion.version_name, " ").concat(activeVersion.version)), updatedVersionsList && updatedVersionsList.length > 0 && playerType === 'default' && /*#__PURE__*/_react["default"].createElement("div", {
265
+ }, "".concat(activeVersion.version_name, " ").concat(activeVersion.version)), updatedVersionsList && updatedVersionsList.length > 0 && (playerType === 'default' || playerType === 'dubbing_review') && /*#__PURE__*/_react["default"].createElement("div", {
266
266
  className: "versions-dropdown-container"
267
267
  }, /*#__PURE__*/_react["default"].createElement("div", {
268
268
  className: "versions-container"
@@ -344,7 +344,7 @@ var PlayerHeader = exports["default"] = /*#__PURE__*/function (_Component) {
344
344
  tabIndex: "0"
345
345
  }, this.props, {
346
346
  onClick: openSharePopup
347
- })), !isFullscreen && !isUserGuest && (playerType === 'default' || playerType === 'qc') && qcReportAvailable && /*#__PURE__*/_react["default"].createElement(QCReportButton, _extends({
347
+ })), !isFullscreen && !isUserGuest && showQCReport.includes(playerType) && qcReportAvailable && /*#__PURE__*/_react["default"].createElement(QCReportButton, _extends({
348
348
  display: "rounded",
349
349
  appearance: "cta",
350
350
  icon: "qc_report",
@@ -20,9 +20,16 @@ var _templateObject, _templateObject2;
20
20
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
21
21
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
22
22
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
23
+ function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
23
24
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
24
25
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
25
- function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
26
+ function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
27
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
28
+ function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
29
+ function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
30
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator["return"] && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, "catch": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
31
+ function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
32
+ function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
26
33
  function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
27
34
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
28
35
  function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
@@ -91,7 +98,8 @@ var propTypes = {
91
98
  onPlayerClose: _propTypes.PropTypes.func,
92
99
  userEmail: _propTypes.PropTypes.string,
93
100
  playerSelectedMarker: _propTypes.PropTypes.instanceOf(Object),
94
- theme: _propTypes.PropTypes.string
101
+ theme: _propTypes.PropTypes.string,
102
+ dubbedTracks: _propTypes.PropTypes.string
95
103
  };
96
104
  var defaultProps = {
97
105
  startTime: 0,
@@ -102,7 +110,8 @@ var defaultProps = {
102
110
  preload: 'auto',
103
111
  aspectRatio: 'auto',
104
112
  crossOrigin: 'anonymous',
105
- theme: 'dark'
113
+ theme: 'dark',
114
+ dubbedTracks: null
106
115
  };
107
116
  var SubTitleSection = _styledComponents["default"].div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n position: absolute;\n font-family: SFUIText-Regular;\n font-size: 16px;\n bottom: 20px;\n width: 100%;\n display: flex;\n justify-content: center;\n text-align: center;\n color: #ffffff;\n height: 90%;\n align-items: center;\n\n .subtitleContainer {\n border-radius: 4px;\n width: fit-content;\n background: #000000;\n opacity: 0.9;\n padding: ", ";\n line-height: 20px;\n position: absolute;\n\n i,\n em {\n font-style: italic; /* Override the font style for <em> tags inside elements with the class .someClass */\n }\n\n strong {\n font-weight: bold;\n }\n }\n .longSubtitleStyles {\n overflow-y: auto;\n height: fit-content;\n max-height: 70px;\n max-width: 75%;\n width: fit-content;\n }\n"])), function (props) {
108
117
  return props.currentSubtitleObj && props.currentSubtitleObj.line1 ? '8px 10px' : '0px';
@@ -243,6 +252,7 @@ var Video = exports["default"] = /*#__PURE__*/function (_Component) {
243
252
  };
244
253
  _this.video = null; // the html5 video
245
254
  _this.manager = new _Manager["default"](props.store);
255
+ _this.dubbedTrackNames = null;
246
256
  _this.getStyle = _this.getStyle.bind(_this);
247
257
  _this.getChildren = _this.getChildren.bind(_this);
248
258
  _this.play = _this.play.bind(_this);
@@ -282,15 +292,144 @@ var Video = exports["default"] = /*#__PURE__*/function (_Component) {
282
292
  _this.updateSvgSize = _this.updateSvgSize.bind(_this);
283
293
  _this.disconnectResizeObserver = _this.disconnectResizeObserver.bind(_this);
284
294
  _this.calculateHeightBasedOnResolution = _this.calculateHeightBasedOnResolution.bind(_this);
295
+ _this.combineM3U8Manifests = _this.combineM3U8Manifests.bind(_this);
285
296
  return _this;
286
297
  }
287
298
  _inherits(Video, _Component);
288
299
  return _createClass(Video, [{
300
+ key: "combineM3U8Manifests",
301
+ value: function () {
302
+ var _combineM3U8Manifests = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(originalUrl, dubbedUrl) {
303
+ var fetchManifest, _yield$Promise$all, _yield$Promise$all2, originalContent, dubbedContent, extractAudioTracks, extractVideoStream, originalBase, dubbedBase, videoStreamUri, originalAudioTracks, dubbedAudioTracks, dubbedTrackNames, allTracksMap, allAudioTracks, combinedManifest, _i, _allAudioTracks, track;
304
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
305
+ while (1) switch (_context2.prev = _context2.next) {
306
+ case 0:
307
+ fetchManifest = /*#__PURE__*/function () {
308
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(url) {
309
+ var response;
310
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
311
+ while (1) switch (_context.prev = _context.next) {
312
+ case 0:
313
+ _context.next = 2;
314
+ return fetch(url);
315
+ case 2:
316
+ response = _context.sent;
317
+ if (response.ok) {
318
+ _context.next = 5;
319
+ break;
320
+ }
321
+ throw new Error("Failed to fetch ".concat(url));
322
+ case 5:
323
+ return _context.abrupt("return", response.text());
324
+ case 6:
325
+ case "end":
326
+ return _context.stop();
327
+ }
328
+ }, _callee);
329
+ }));
330
+ return function fetchManifest(_x3) {
331
+ return _ref.apply(this, arguments);
332
+ };
333
+ }();
334
+ _context2.next = 3;
335
+ return Promise.all([fetchManifest(originalUrl), fetchManifest(dubbedUrl)]);
336
+ case 3:
337
+ _yield$Promise$all = _context2.sent;
338
+ _yield$Promise$all2 = _slicedToArray(_yield$Promise$all, 2);
339
+ originalContent = _yield$Promise$all2[0];
340
+ dubbedContent = _yield$Promise$all2[1];
341
+ extractAudioTracks = function extractAudioTracks(content, baseUrl) {
342
+ var lines = content.split(/\r?\n/);
343
+ var audioTracks = [];
344
+ for (var i = 0; i < lines.length; i++) {
345
+ var line = lines[i];
346
+ if (line.startsWith('#EXT-X-MEDIA:TYPE=AUDIO')) {
347
+ var groupIdMatch = line.match(/GROUP-ID="([^"]+)"/);
348
+ var nameMatch = line.match(/NAME="([^"]+)"/);
349
+ var uriMatch = line.match(/URI="([^"]+)"/);
350
+ var languageMatch = line.match(/LANGUAGE="([^"]+)"/);
351
+ var defaultMatch = line.match(/DEFAULT=(\w+)/);
352
+ var autoselectMatch = line.match(/AUTOSELECT=(\w+)/);
353
+ if (groupIdMatch && nameMatch && uriMatch) {
354
+ var uri = uriMatch[1];
355
+ if (!uri.startsWith('http://') && !uri.startsWith('https://') && !uri.startsWith('//')) {
356
+ var base = baseUrl.substring(0, baseUrl.lastIndexOf('/') + 1);
357
+ uri = new URL(uri, base).href;
358
+ }
359
+ audioTracks.push({
360
+ groupId: groupIdMatch[1],
361
+ name: nameMatch[1],
362
+ uri: uri,
363
+ language: languageMatch ? languageMatch[1] : nameMatch[1],
364
+ "default": defaultMatch ? defaultMatch[1] === 'YES' : false,
365
+ autoselect: autoselectMatch ? autoselectMatch[1] === 'YES' : true
366
+ });
367
+ }
368
+ }
369
+ }
370
+ return audioTracks;
371
+ };
372
+ extractVideoStream = function extractVideoStream(content, baseUrl) {
373
+ var lines = content.split(/\r?\n/);
374
+ for (var i = 0; i < lines.length; i++) {
375
+ if (lines[i].startsWith('#EXT-X-STREAM-INF')) {
376
+ var videoUri = lines[i + 1];
377
+ if (videoUri && !videoUri.startsWith('#')) {
378
+ if (!videoUri.startsWith('http://') && !videoUri.startsWith('https://') && !videoUri.startsWith('//')) {
379
+ var base = baseUrl.substring(0, baseUrl.lastIndexOf('/') + 1);
380
+ return new URL(videoUri, base).href;
381
+ }
382
+ return videoUri;
383
+ }
384
+ }
385
+ }
386
+ throw new Error('No video stream found in original manifest');
387
+ };
388
+ originalBase = originalUrl;
389
+ dubbedBase = dubbedUrl;
390
+ videoStreamUri = extractVideoStream(originalContent, originalBase);
391
+ originalAudioTracks = extractAudioTracks(originalContent, originalBase);
392
+ dubbedAudioTracks = extractAudioTracks(dubbedContent, dubbedBase);
393
+ dubbedTrackNames = dubbedAudioTracks.map(function (track) {
394
+ return track.name;
395
+ });
396
+ allTracksMap = new Map();
397
+ [].concat(_toConsumableArray(originalAudioTracks), _toConsumableArray(dubbedAudioTracks)).forEach(function (track) {
398
+ var key = track.name || track.language;
399
+ if (!allTracksMap.has(key)) {
400
+ allTracksMap.set(key, track);
401
+ }
402
+ });
403
+ allAudioTracks = Array.from(allTracksMap.values());
404
+ combinedManifest = '#EXTM3U\n';
405
+ combinedManifest += '#EXT-X-VERSION:6\n\n';
406
+ combinedManifest += '#EXT-X-STREAM-INF:BANDWIDTH=800000,RESOLUTION=640x360,AUDIO="audio"\n';
407
+ combinedManifest += "".concat(videoStreamUri, "\n\n");
408
+ for (_i = 0, _allAudioTracks = allAudioTracks; _i < _allAudioTracks.length; _i++) {
409
+ track = _allAudioTracks[_i];
410
+ combinedManifest += "#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID=\"audio\",LANGUAGE=\"".concat(track.language, "\",NAME=\"").concat(track.name, "\",AUTOSELECT=").concat(track.autoselect ? 'YES' : 'NO', ",DEFAULT=").concat(track["default"] ? 'YES' : 'NO', ",URI=\"").concat(track.uri, "\"\n");
411
+ }
412
+ return _context2.abrupt("return", {
413
+ combinedManifest: combinedManifest,
414
+ dubbedTrackNames: dubbedTrackNames
415
+ });
416
+ case 24:
417
+ case "end":
418
+ return _context2.stop();
419
+ }
420
+ }, _callee2);
421
+ }));
422
+ function combineM3U8Manifests(_x, _x2) {
423
+ return _combineM3U8Manifests.apply(this, arguments);
424
+ }
425
+ return combineM3U8Manifests;
426
+ }()
427
+ }, {
289
428
  key: "componentDidMount",
290
429
  value: function componentDidMount() {
291
430
  var _this2 = this;
292
431
  var src = this.props.src;
293
- var isM3U8 = src.split('.').pop() === 'm3u8' ? true : false;
432
+ var isM3U8 = src.split('.').pop() === 'm3u8';
294
433
  this.setState({
295
434
  isM3U8: isM3U8
296
435
  });
@@ -302,7 +441,7 @@ var Video = exports["default"] = /*#__PURE__*/function (_Component) {
302
441
  } else {
303
442
  this.video.src = src;
304
443
  }
305
- this.forceUpdate(); // make sure the children can get the video property
444
+ this.forceUpdate();
306
445
  var watermarkInterval = setInterval(this.checkWatermark, 40000);
307
446
  this.setState({
308
447
  watermarkInterval: watermarkInterval
@@ -362,9 +501,12 @@ var Video = exports["default"] = /*#__PURE__*/function (_Component) {
362
501
  isM3U8 = _this$state.isM3U8,
363
502
  watermarkInterval = _this$state.watermarkInterval;
364
503
  if (_hls["default"].isSupported() && isM3U8) {
365
- this.hls.detachMedia();
504
+ if (this.hls) {
505
+ this.hls.detachMedia();
506
+ this.hls.destroy();
507
+ }
366
508
  } else {
367
- this.video.src = '';
509
+ if (this.video) this.video.src = '';
368
510
  }
369
511
  clearInterval(watermarkInterval);
370
512
  if (this.video) {
@@ -373,6 +515,10 @@ var Video = exports["default"] = /*#__PURE__*/function (_Component) {
373
515
  }
374
516
  window.removeEventListener('resize', this.calculateHeightBasedOnResolution);
375
517
  this.disconnectResizeObserver();
518
+ if (this.combinedManifestUrl) {
519
+ URL.revokeObjectURL(this.combinedManifestUrl);
520
+ this.combinedManifestUrl = null;
521
+ }
376
522
  }
377
523
  }, {
378
524
  key: "checkWatermark",
@@ -415,38 +561,69 @@ var Video = exports["default"] = /*#__PURE__*/function (_Component) {
415
561
  }
416
562
  }, {
417
563
  key: "setupHLS",
418
- value: function setupHLS(src) {
564
+ value: function setupHLS(originalSrc) {
419
565
  var _this4 = this;
566
+ var dubbedTracksOverride = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
420
567
  var _this$props6 = this.props,
421
568
  actions = _this$props6.actions,
422
569
  activeTrackIndex = _this$props6.activeTrackIndex;
423
570
  var self = this;
424
- // bind them together
425
- this.hls.attachMedia(this.video);
426
- this.hls.on(_hls["default"].Events.MEDIA_ATTACHED, function () {
427
- self.hls.loadSource(src);
428
- });
571
+ var effectiveDubbedTracks = dubbedTracksOverride !== undefined ? dubbedTracksOverride : this.props.dubbedTracks;
572
+ var attachAndLoad = function attachAndLoad(sourceUrl) {
573
+ if (!self.hls) return;
574
+ self.hls.attachMedia(self.video);
575
+ self.hls.on(_hls["default"].Events.MEDIA_ATTACHED, function () {
576
+ self.hls.loadSource(sourceUrl);
577
+ });
578
+ };
579
+ if (effectiveDubbedTracks && effectiveDubbedTracks.length && effectiveDubbedTracks.trim() !== '') {
580
+ this.combineM3U8Manifests(originalSrc, effectiveDubbedTracks).then(function (_ref2) {
581
+ var combinedManifest = _ref2.combinedManifest,
582
+ dubbedTrackNames = _ref2.dubbedTrackNames;
583
+ // Store the list of dubbed track names
584
+ self.dubbedTrackNames = dubbedTrackNames;
585
+ var blob = new Blob([combinedManifest], {
586
+ type: 'application/vnd.apple.mpegurl'
587
+ });
588
+ var combinedUrl = URL.createObjectURL(blob);
589
+ _this4.combinedManifestUrl = combinedUrl;
590
+ attachAndLoad(combinedUrl);
591
+ })["catch"](function (err) {
592
+ console.error('Failed to combine manifests, falling back to original', err);
593
+ self.dubbedTrackNames = [];
594
+ attachAndLoad(originalSrc);
595
+ });
596
+ } else {
597
+ self.dubbedTrackNames = [];
598
+ attachAndLoad(originalSrc);
599
+ }
429
600
  this.hls.on(_hls["default"].Events.MANIFEST_PARSED, function (event, data) {
430
- actions.handleAudioTracks(data.audioTracks);
601
+ // Add isDubbedTrack flag to audio tracks
602
+ var audioTracksWithFlag = (data.audioTracks || []).map(function (track) {
603
+ if (self.dubbedTrackNames && self.dubbedTrackNames.includes(track.name)) {
604
+ return _objectSpread(_objectSpread({}, track), {}, {
605
+ isDubbedTrack: true
606
+ });
607
+ }
608
+ return track;
609
+ });
610
+ actions.handleAudioTracks(audioTracksWithFlag);
431
611
  });
432
612
  this.hls.once(_hls["default"].Events.AUDIO_TRACK_LOADED, function (event, data) {
433
613
  var trackIndex = activeTrackIndex || 0;
434
614
  actions.handleAudioTrackChange(self.props.player.audioTracksArr[trackIndex]);
435
615
  });
436
616
  this.hls.on(_hls["default"].Events.ERROR, function (event, data) {
437
- // eslint-disable-next-line no-console
438
617
  console.log('HLS.Events.ERROR: ', event, data);
439
618
  if (data.fatal) {
440
619
  switch (data.type) {
441
620
  case _hls["default"].ErrorTypes.NETWORK_ERROR:
442
- // try to recover network error
443
621
  _this4.hls.startLoad();
444
622
  break;
445
623
  case _hls["default"].ErrorTypes.MEDIA_ERROR:
446
624
  _this4.hls.recoverMediaError();
447
625
  break;
448
626
  default:
449
- // cannot recover
450
627
  _this4.hls.destroy();
451
628
  break;
452
629
  }
@@ -656,6 +833,7 @@ var Video = exports["default"] = /*#__PURE__*/function (_Component) {
656
833
  value: function UNSAFE_componentWillReceiveProps(newProps) {
657
834
  var _this$props9 = this.props,
658
835
  src = _this$props9.src,
836
+ dubbedTracks = _this$props9.dubbedTracks,
659
837
  activeAudio = _this$props9.player.activeAudio,
660
838
  currentSubtitleObj = _this$props9.currentSubtitleObj,
661
839
  markers = _this$props9.markers,
@@ -663,14 +841,21 @@ var Video = exports["default"] = /*#__PURE__*/function (_Component) {
663
841
  if (markers && markers !== newProps.markers && newProps.markers) {
664
842
  this.displaySubtitle(newProps.markers);
665
843
  }
666
- if (newProps.src !== src) {
844
+ if (newProps.src !== src || newProps.dubbedTracks !== dubbedTracks) {
667
845
  var isM3U8 = this.state.isM3U8;
668
846
  if (_hls["default"].isSupported() && isM3U8) {
669
- this.hls.detachMedia();
670
- } else {
847
+ if (this.hls) {
848
+ this.hls.detachMedia();
849
+ this.hls.destroy();
850
+ }
851
+ } else if (this.video) {
671
852
  this.video.src = '';
672
853
  }
673
- var m3u8 = newProps.src.split('.').pop() === 'm3u8' ? true : false;
854
+ if (this.combinedManifestUrl) {
855
+ URL.revokeObjectURL(this.combinedManifestUrl);
856
+ this.combinedManifestUrl = null;
857
+ }
858
+ var m3u8 = newProps.src.split('.').pop() === 'm3u8';
674
859
  this.setState({
675
860
  isM3U8: m3u8
676
861
  });
@@ -678,13 +863,13 @@ var Video = exports["default"] = /*#__PURE__*/function (_Component) {
678
863
  var _this$manager$getStat3 = this.manager.getState(),
679
864
  HLSConfig = _this$manager$getStat3.player.HLSConfig;
680
865
  this.hls = new _hls["default"](HLSConfig);
681
- this.setupHLS(newProps.src);
682
- } else {
866
+ this.setupHLS(newProps.src, newProps.dubbedTracks);
867
+ } else if (this.video) {
683
868
  this.video.src = newProps.src;
684
869
  }
685
- this.forceUpdate(); // make sure the children can get the video property
870
+ this.forceUpdate();
686
871
  }
687
- if (newProps.player.activeAudio && activeAudio && activeAudio.id !== newProps.player.activeAudio.id) {
872
+ if (newProps.player.activeAudio && activeAudio && activeAudio.id !== newProps.player.activeAudio.id && this.hls) {
688
873
  this.hls.audioTrack = newProps.player.activeAudio.id;
689
874
  }
690
875
  if (newProps.subtitleObj && newProps.subtitleObj.field && JSON.stringify(newProps.subtitleObj) !== JSON.stringify(currentSubtitleObj)) {
@@ -10,15 +10,14 @@ var _react = _interopRequireWildcard(require("react"));
10
10
  var _styledComponents = _interopRequireDefault(require("styled-components"));
11
11
  var _Menu = _interopRequireDefault(require("../Menu"));
12
12
  var _tokens = require("@desynova-digital/tokens");
13
- var _templateObject;
13
+ var _components = require("@desynova-digital/components");
14
+ var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9;
14
15
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
15
16
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
16
17
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
17
18
  function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
18
19
  function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
19
20
  function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
20
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
21
- function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
22
21
  function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
23
22
  function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }
24
23
  function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
@@ -26,22 +25,100 @@ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.
26
25
  function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
27
26
  function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); }
28
27
  function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
28
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
29
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
30
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
29
31
  function _taggedTemplateLiteral(e, t) { return t || (t = e.slice(0)), Object.freeze(Object.defineProperties(e, { raw: { value: Object.freeze(t) } })); }
30
32
  var propTypes = {
31
33
  actions: _propTypes.PropTypes.instanceOf(Object),
32
34
  player: _propTypes.PropTypes.instanceOf(Object),
33
35
  theme: _propTypes.PropTypes.string
34
36
  };
35
- var AudioTrackBlock = (0, _styledComponents["default"])('div')(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n text-align: left;\n background: transparent;\n cursor: pointer;\n border-bottom: 1px solid #eeeeee;\n &:last-child {\n border: none;\n }\n &:hover,\n &:focus {\n background: ", ";\n }\n p {\n padding 15px;\n font-family: SFUIText-Medium;\n font-size: 12px;\n white-space: nowrap;\n }\n"])), function (props) {
37
+ var AudioTrackBlock = (0, _styledComponents["default"])('div')(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n text-align: left;\n background: transparent;\n cursor: pointer;\n border-bottom: 1px solid #eeeeee;\n &:last-child {\n border: none;\n }\n &:hover,\n &:focus {\n background: ", ";\n }\n p {\n padding: 15px;\n font-family: SFUIText-Medium;\n font-size: 12px;\n white-space: nowrap;\n }\n"])), function (props) {
36
38
  return props.theme ? " ".concat(_tokens.colors[props.theme].videoPlayer.rgbaThemeColor) : 'rgba(0, 206, 198, 0.1)';
37
39
  });
40
+ var AccordionContainer = _styledComponents["default"].div(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n width: 100%;\n"])));
41
+ var AccordionHeader = _styledComponents["default"].div(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n display: flex;\n justify-content: space-between;\n align-items: center;\n padding: 12px 15px;\n background: ", ";\n cursor: pointer;\n border-bottom: 1px solid #eeeeee;\n font-family: SFUIText-Medium;\n font-size: 13px;\n font-weight: 500;\n color: ", ";\n &:hover {\n background: ", ";\n }\n"])), function (props) {
42
+ return props.theme ? "".concat(_tokens.colors[props.theme].videoPlayer.rgbaThemeColor, "10") : 'rgba(0, 206, 198, 0.05)';
43
+ }, function (props) {
44
+ return props.theme ? _tokens.colors[props.theme].videoPlayer.themeColor : '#00cec6';
45
+ }, function (props) {
46
+ return props.theme ? "".concat(_tokens.colors[props.theme].videoPlayer.rgbaThemeColor, "20") : 'rgba(0, 206, 198, 0.1)';
47
+ });
48
+ var HeaderTitle = _styledComponents["default"].span(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n user-select: none;\n color: #999999;\n"])));
49
+ var HeaderIcon = _styledComponents["default"].span(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n font-size: 12px;\n transition: transform 0.2s ease;\n transform: ", ";\n"])), function (props) {
50
+ return props.isOpen ? 'rotate(180deg)' : 'rotate(0deg)';
51
+ });
52
+ var AccordionContent = _styledComponents["default"].div(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n overflow: hidden;\n transition: max-height 0.25s ease-in-out;\n max-height: ", ";\n"])), function (props) {
53
+ return props.isOpen ? '500px' : '0';
54
+ });
55
+ var NowPlayingContainer = _styledComponents["default"].div(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["\n padding: 12px 15px;\n border-bottom: 1px solid #eeeeee;\n margin-bottom: 4px;\n"])));
56
+ var NowPlayingLabel = _styledComponents["default"].div(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["\n font-family: SFUIText-Medium;\n font-size: 11px;\n letter-spacing: 0.5px;\n color: #999999;\n margin-bottom: 6px;\n"])));
57
+ var NowPlayingTrackName = _styledComponents["default"].div(_templateObject9 || (_templateObject9 = _taggedTemplateLiteral(["\n font-family: SFUIText-Medium;\n font-size: 14px;\n font-weight: 500;\n color: #333333;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n"])));
38
58
  var AudioTracksMenuButton = /*#__PURE__*/function (_Component) {
39
59
  function AudioTracksMenuButton(props, context) {
60
+ var _this;
40
61
  _classCallCheck(this, AudioTracksMenuButton);
41
- return _callSuper(this, AudioTracksMenuButton, [props, context]);
62
+ _this = _callSuper(this, AudioTracksMenuButton, [props, context]);
63
+ _defineProperty(_this, "toggleOriginalAccordion", function () {
64
+ _this.setState(function (prevState) {
65
+ return {
66
+ openAccordion: prevState.openAccordion === 'original' ? null : 'original'
67
+ };
68
+ });
69
+ });
70
+ _defineProperty(_this, "toggleDubbedAccordion", function () {
71
+ _this.setState(function (prevState) {
72
+ return {
73
+ openAccordion: prevState.openAccordion === 'dubbed' ? null : 'dubbed'
74
+ };
75
+ });
76
+ });
77
+ _this.state = {
78
+ openAccordion: 'original'
79
+ };
80
+ return _this;
42
81
  }
43
82
  _inherits(AudioTracksMenuButton, _Component);
44
83
  return _createClass(AudioTracksMenuButton, [{
84
+ key: "componentDidMount",
85
+ value: function componentDidMount() {
86
+ this.ensureValidAudioTrack();
87
+ }
88
+ }, {
89
+ key: "componentDidUpdate",
90
+ value: function componentDidUpdate(prevProps) {
91
+ var _prevProps$player, _this$props$player, _prevProps$player2, _this$props$player2;
92
+ var prevTracks = (_prevProps$player = prevProps.player) === null || _prevProps$player === void 0 ? void 0 : _prevProps$player.audioTracksArr;
93
+ var currentTracks = (_this$props$player = this.props.player) === null || _this$props$player === void 0 ? void 0 : _this$props$player.audioTracksArr;
94
+ var prevActiveAudio = (_prevProps$player2 = prevProps.player) === null || _prevProps$player2 === void 0 ? void 0 : _prevProps$player2.activeAudio;
95
+ var currentActiveAudio = (_this$props$player2 = this.props.player) === null || _this$props$player2 === void 0 ? void 0 : _this$props$player2.activeAudio;
96
+ if (prevTracks !== currentTracks || (prevActiveAudio === null || prevActiveAudio === void 0 ? void 0 : prevActiveAudio.id) !== (currentActiveAudio === null || currentActiveAudio === void 0 ? void 0 : currentActiveAudio.id)) {
97
+ this.ensureValidAudioTrack();
98
+ }
99
+ }
100
+ }, {
101
+ key: "ensureValidAudioTrack",
102
+ value: function ensureValidAudioTrack() {
103
+ var _this$props = this.props,
104
+ player = _this$props.player,
105
+ actions = _this$props.actions;
106
+ var allTracks = player.audioTracksArr || [];
107
+ if (allTracks.length === 0) return;
108
+ var currentActive = player.activeAudio;
109
+ var isCurrentTrackValid = currentActive && allTracks.some(function (track) {
110
+ return track.id === currentActive.id;
111
+ });
112
+ if (!isCurrentTrackValid) {
113
+ var firstOriginalTrack = allTracks.find(function (track) {
114
+ return track.autoselect;
115
+ });
116
+ if (firstOriginalTrack) {
117
+ actions.handleAudioTrackChange(firstOriginalTrack);
118
+ }
119
+ }
120
+ }
121
+ }, {
45
122
  key: "changeTrack",
46
123
  value: function changeTrack(track) {
47
124
  var actions = this.props.actions;
@@ -50,12 +127,27 @@ var AudioTracksMenuButton = /*#__PURE__*/function (_Component) {
50
127
  }, {
51
128
  key: "render",
52
129
  value: function render() {
53
- var _this = this;
54
- var _this$props = this.props,
55
- player = _this$props.player,
56
- actions = _this$props.actions,
57
- theme = _this$props.theme;
58
- return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, player.audioTracksArr && player.audioTracksArr.length ? /*#__PURE__*/_react["default"].createElement(_Menu["default"], {
130
+ var _player$activeAudio,
131
+ _this2 = this;
132
+ var _this$props2 = this.props,
133
+ player = _this$props2.player,
134
+ actions = _this$props2.actions,
135
+ theme = _this$props2.theme;
136
+ var openAccordion = this.state.openAccordion;
137
+ var allTracks = player.audioTracksArr || [];
138
+ var originalTracks = allTracks.filter(function (track) {
139
+ return !track.isDubbedTrack;
140
+ });
141
+ var dubbedTracks = allTracks.filter(function (track) {
142
+ return track.isDubbedTrack === true;
143
+ });
144
+ var currentTrackName = ((_player$activeAudio = player.activeAudio) === null || _player$activeAudio === void 0 ? void 0 : _player$activeAudio.name) || 'No track playing';
145
+ var hasOriginalTracks = originalTracks.length > 0;
146
+ var hasDubbedTracks = dubbedTracks.length > 0;
147
+ if (!hasOriginalTracks && !hasDubbedTracks) {
148
+ return null;
149
+ }
150
+ return /*#__PURE__*/_react["default"].createElement(_Menu["default"], {
59
151
  theme: theme,
60
152
  icon: "audio-track",
61
153
  player: player,
@@ -66,11 +158,52 @@ var AudioTracksMenuButton = /*#__PURE__*/function (_Component) {
66
158
  position: "left"
67
159
  }, /*#__PURE__*/_react["default"].createElement("div", {
68
160
  className: "menu-container"
69
- }, player.audioTracksArr.map(function (track) {
161
+ }, hasDubbedTracks && /*#__PURE__*/_react["default"].createElement(NowPlayingContainer, null, /*#__PURE__*/_react["default"].createElement(NowPlayingLabel, null, "Now playing"), /*#__PURE__*/_react["default"].createElement(NowPlayingTrackName, {
162
+ theme: theme
163
+ }, currentTrackName)), hasDubbedTracks && /*#__PURE__*/_react["default"].createElement(AccordionContainer, null, /*#__PURE__*/_react["default"].createElement(AccordionHeader, {
164
+ theme: theme,
165
+ onClick: this.toggleDubbedAccordion
166
+ }, /*#__PURE__*/_react["default"].createElement(HeaderTitle, null, "Dubbed tracks"), /*#__PURE__*/_react["default"].createElement(HeaderIcon, {
167
+ isOpen: openAccordion === 'dubbed'
168
+ }, /*#__PURE__*/_react["default"].createElement(_components.Icon, {
169
+ color: "#999999",
170
+ name: "dropdown_more_icon"
171
+ }))), /*#__PURE__*/_react["default"].createElement(AccordionContent, {
172
+ isOpen: openAccordion === 'dubbed'
173
+ }, dubbedTracks.map(function (track, index) {
174
+ return /*#__PURE__*/_react["default"].createElement(AudioTrackBlock, {
175
+ theme: theme,
176
+ onClick: function onClick() {
177
+ return _this2.changeTrack(track);
178
+ },
179
+ role: "presentation",
180
+ key: track.id || index,
181
+ style: player.activeAudio && player.activeAudio.id === track.id ? {
182
+ pointerEvents: 'none'
183
+ } : null
184
+ }, /*#__PURE__*/_react["default"].createElement("p", {
185
+ style: player.activeAudio && player.activeAudio.id === track.id ? {
186
+ color: theme ? "".concat(_tokens.colors[theme].videoPlayer.themeColor) : '#00cec6',
187
+ pointerEvents: 'none'
188
+ } : {
189
+ color: '#333333'
190
+ }
191
+ }, track.name || "Dubbed Track ".concat(index + 1)));
192
+ }))), hasOriginalTracks && /*#__PURE__*/_react["default"].createElement(AccordionContainer, null, hasDubbedTracks && /*#__PURE__*/_react["default"].createElement(AccordionHeader, {
193
+ theme: theme,
194
+ onClick: this.toggleOriginalAccordion
195
+ }, /*#__PURE__*/_react["default"].createElement(HeaderTitle, null, "Original tracks"), /*#__PURE__*/_react["default"].createElement(HeaderIcon, {
196
+ isOpen: openAccordion === 'original'
197
+ }, /*#__PURE__*/_react["default"].createElement(_components.Icon, {
198
+ color: "#999999",
199
+ name: "dropdown_more_icon"
200
+ }))), /*#__PURE__*/_react["default"].createElement(AccordionContent, {
201
+ isOpen: openAccordion === 'original'
202
+ }, originalTracks.map(function (track) {
70
203
  return /*#__PURE__*/_react["default"].createElement(AudioTrackBlock, {
71
204
  theme: theme,
72
205
  onClick: function onClick() {
73
- return _this.changeTrack(track);
206
+ return _this2.changeTrack(track);
74
207
  },
75
208
  role: "presentation",
76
209
  key: track.id,
@@ -79,13 +212,13 @@ var AudioTracksMenuButton = /*#__PURE__*/function (_Component) {
79
212
  } : null
80
213
  }, /*#__PURE__*/_react["default"].createElement("p", {
81
214
  style: player.activeAudio && player.activeAudio.id === track.id ? {
82
- color: theme ? " ".concat(_tokens.colors[theme].videoPlayer.themeColor) : '#00cec6',
215
+ color: theme ? "".concat(_tokens.colors[theme].videoPlayer.themeColor) : '#00cec6',
83
216
  pointerEvents: 'none'
84
217
  } : {
85
218
  color: '#333333'
86
219
  }
87
- }, track.name));
88
- }))) : null);
220
+ }, track.name || ''));
221
+ })))));
89
222
  }
90
223
  }]);
91
224
  }(_react.Component);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@desynova-digital/player",
3
- "version": "4.1.6",
3
+ "version": "4.1.8",
4
4
  "description": "Video Player Package for Contido Application",
5
5
  "main": "index.js",
6
6
  "scripts": {