@mediakind/mkplayer 1.7.0 → 1.8.0

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 (104) hide show
  1. package/mkplayer.js +1 -1
  2. package/package.json +2 -2
  3. package/types/alias/index.d.ts +1 -1
  4. package/types/classes/common/MKAzukiResponseUtils.js +66 -58
  5. package/types/classes/common/MKAzukiResponseUtils.js.map +1 -1
  6. package/types/classes/common/MKEventBase.js +11 -10
  7. package/types/classes/common/MKEventBase.js.map +1 -1
  8. package/types/classes/common/MKLocalStorage.js +64 -58
  9. package/types/classes/common/MKLocalStorage.js.map +1 -1
  10. package/types/classes/common/MKLog.js +49 -22
  11. package/types/classes/common/MKLog.js.map +1 -1
  12. package/types/classes/common/MKPlatform.js +156 -108
  13. package/types/classes/common/MKPlatform.js.map +1 -1
  14. package/types/classes/common/MKProgramManager.js +37 -32
  15. package/types/classes/common/MKProgramManager.js.map +1 -1
  16. package/types/classes/common/MKSecureUrlManager.js +137 -108
  17. package/types/classes/common/MKSecureUrlManager.js.map +1 -1
  18. package/types/classes/common/MKSubtitleOverlay.js +69 -67
  19. package/types/classes/common/MKSubtitleOverlay.js.map +1 -1
  20. package/types/classes/common/MKThumbnailManager.js +261 -211
  21. package/types/classes/common/MKThumbnailManager.js.map +1 -1
  22. package/types/classes/common/MKUtils.js +162 -100
  23. package/types/classes/common/MKUtils.js.map +1 -1
  24. package/types/classes/error/MKAdobeSessionConcurrencyError.js +6 -5
  25. package/types/classes/error/MKAdobeSessionConcurrencyError.js.map +1 -1
  26. package/types/classes/error/MKAzukiRequestError.js +8 -7
  27. package/types/classes/error/MKAzukiRequestError.js.map +1 -1
  28. package/types/classes/error/MKBitmovinPlayerError.js +31 -12
  29. package/types/classes/error/MKBitmovinPlayerError.js.map +1 -1
  30. package/types/classes/error/MKHttpError.js +4 -3
  31. package/types/classes/error/MKHttpError.js.map +1 -1
  32. package/types/classes/error/MKPlayerError.js +5 -4
  33. package/types/classes/error/MKPlayerError.js.map +1 -1
  34. package/types/classes/error/MKProgramRestrictionError.js +11 -10
  35. package/types/classes/error/MKProgramRestrictionError.js.map +1 -1
  36. package/types/classes/player/MKBitmovinPlayer.js +620 -553
  37. package/types/classes/player/MKBitmovinPlayer.js.map +1 -1
  38. package/types/classes/player/MKPlayer.d.ts +4 -0
  39. package/types/classes/player/MKPlayer.js +734 -528
  40. package/types/classes/player/MKPlayer.js.map +1 -1
  41. package/types/classes/player/MKStubPlayer.js +263 -273
  42. package/types/classes/player/MKStubPlayer.js.map +1 -1
  43. package/types/classes/request/MKAdobeSessionConcurrencyRequest.js +198 -127
  44. package/types/classes/request/MKAdobeSessionConcurrencyRequest.js.map +1 -1
  45. package/types/classes/request/MKAzukiRequest.js +381 -268
  46. package/types/classes/request/MKAzukiRequest.js.map +1 -1
  47. package/types/classes/request/MKHttpRequest.js +128 -89
  48. package/types/classes/request/MKHttpRequest.js.map +1 -1
  49. package/types/constants/MKAzukiRequestEndpoint.js +24 -24
  50. package/types/constants/MKAzukiRequestEndpoint.js.map +1 -1
  51. package/types/constants/MKConstants.js +1 -1
  52. package/types/enums/MKAnalyticsDataName.d.ts +8 -0
  53. package/types/enums/MKAnalyticsDataName.js +13 -0
  54. package/types/enums/MKAnalyticsDataName.js.map +1 -0
  55. package/types/enums/MKErrorCode.d.ts +1 -0
  56. package/types/enums/MKErrorCode.js +1 -0
  57. package/types/enums/MKErrorCode.js.map +1 -1
  58. package/types/enums/MKPlayerEvent.d.ts +6 -1
  59. package/types/enums/MKPlayerEvent.js +5 -0
  60. package/types/enums/MKPlayerEvent.js.map +1 -1
  61. package/types/enums/MKProgramRestrictionType.js.map +1 -1
  62. package/types/enums/index.d.ts +1 -0
  63. package/types/enums/index.js +3 -1
  64. package/types/enums/index.js.map +1 -1
  65. package/types/interfaces/MKAdaptationPlatformConfig.js +1 -1
  66. package/types/interfaces/MKAdaptationPlatformConfig.js.map +1 -1
  67. package/types/interfaces/MKBufferConfig.js +1 -1
  68. package/types/interfaces/MKBufferConfig.js.map +1 -1
  69. package/types/interfaces/MKBufferMediaTypeConfig.js +1 -1
  70. package/types/interfaces/MKBufferMediaTypeConfig.js.map +1 -1
  71. package/types/interfaces/MKDrmConfig.js +1 -1
  72. package/types/interfaces/MKDrmConfig.js.map +1 -1
  73. package/types/interfaces/MKRegisteredSource.d.ts +1 -0
  74. package/types/interfaces/events/MKAnalyticsDataEvent.d.ts +6 -0
  75. package/types/interfaces/events/MKAnalyticsDataEvent.js +3 -0
  76. package/types/interfaces/events/MKAnalyticsDataEvent.js.map +1 -0
  77. package/types/interfaces/events/MKAudioPlaybackQualityChangedEvent.d.ts +2 -1
  78. package/types/interfaces/events/MKMediaPlaybackQualityChangeEvent.d.ts +3 -3
  79. package/types/interfaces/events/MKVSPPSessionIdEvent.d.ts +4 -0
  80. package/types/interfaces/events/MKVSPPSessionIdEvent.js +3 -0
  81. package/types/interfaces/events/MKVSPPSessionIdEvent.js.map +1 -0
  82. package/types/interfaces/events/MKVideoPlaybackQualityChangedEvent.d.ts +2 -1
  83. package/types/interfaces/events/index.d.ts +2 -0
  84. package/types/src/alias/index.d.ts +1 -1
  85. package/types/src/classes/player/MKPlayer.d.ts +4 -0
  86. package/types/src/enums/MKAnalyticsDataName.d.ts +8 -0
  87. package/types/src/enums/MKErrorCode.d.ts +1 -0
  88. package/types/src/enums/MKPlayerEvent.d.ts +6 -1
  89. package/types/src/enums/index.d.ts +1 -0
  90. package/types/src/interfaces/MKRegisteredSource.d.ts +1 -0
  91. package/types/src/interfaces/events/MKAnalyticsDataEvent.d.ts +6 -0
  92. package/types/src/interfaces/events/MKAudioPlaybackQualityChangedEvent.d.ts +2 -1
  93. package/types/src/interfaces/events/MKMediaPlaybackQualityChangeEvent.d.ts +3 -3
  94. package/types/src/interfaces/events/MKVSPPSessionIdEvent.d.ts +4 -0
  95. package/types/src/interfaces/events/MKVideoPlaybackQualityChangedEvent.d.ts +2 -1
  96. package/types/src/interfaces/events/index.d.ts +2 -0
  97. package/types/plugins/fmts/MKFMTSConfig.d.ts +0 -10
  98. package/types/plugins/fmts/MKFMTSController.d.ts +0 -39
  99. package/types/plugins/fmts/MKFMTSUtils.d.ts +0 -4
  100. package/types/plugins/fmts/index.d.ts +0 -2
  101. package/types/plugins/omsdk/MKOMSDKConfig.d.ts +0 -6
  102. package/types/plugins/omsdk/MKOMSDKConstants.d.ts +0 -152
  103. package/types/plugins/omsdk/MKOMSDKController.d.ts +0 -58
  104. package/types/plugins/omsdk/index.d.ts +0 -2
@@ -1,4 +1,19 @@
1
1
  "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
+ extendStatics(d, b);
13
+ function __() { this.constructor = d; }
14
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
+ };
16
+ })();
2
17
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
18
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
19
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -8,286 +23,384 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
23
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
24
  });
10
25
  };
26
+ var __generator = (this && this.__generator) || function (thisArg, body) {
27
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
28
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
29
+ function verb(n) { return function (v) { return step([n, v]); }; }
30
+ function step(op) {
31
+ if (f) throw new TypeError("Generator is already executing.");
32
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
33
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
34
+ if (y = 0, t) op = [op[0] & 2, t.value];
35
+ switch (op[0]) {
36
+ case 0: case 1: t = op; break;
37
+ case 4: _.label++; return { value: op[1], done: false };
38
+ case 5: _.label++; y = op[1]; op = [0]; continue;
39
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
40
+ default:
41
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
42
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
43
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
44
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
45
+ if (t[2]) _.ops.pop();
46
+ _.trys.pop(); continue;
47
+ }
48
+ op = body.call(thisArg, _);
49
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
50
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
51
+ }
52
+ };
11
53
  Object.defineProperty(exports, "__esModule", { value: true });
12
54
  exports.MKAzukiRequest = void 0;
13
- const MKUtils_1 = require("../common/MKUtils");
14
- const MKHttpRequest_1 = require("./MKHttpRequest");
15
- const enums_1 = require("../../enums");
16
- const error_1 = require("../error");
17
- const constants_1 = require("../../constants");
18
- const common_1 = require("../common");
19
- class MKAzukiRequest extends MKHttpRequest_1.MKHttpRequest {
20
- constructor(sourceConfig, errorCallback) {
21
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
22
- super();
23
- this.sessionManager = "azuki";
24
- this.beaconInterval = 0;
25
- this.errorCallback = errorCallback;
26
- this.localStorage = common_1.MKLocalStorage.getInstance();
27
- this.mediaId = (_b = (_a = sourceConfig.registered) === null || _a === void 0 ? void 0 : _a.mediaId) !== null && _b !== void 0 ? _b : "";
28
- this.ownerUid = (_d = (_c = sourceConfig.registered) === null || _c === void 0 ? void 0 : _c.environmentConfig.ownerUid) !== null && _d !== void 0 ? _d : constants_1.MKConstants.AzukiDefaultOwnerUid;
29
- this.sessionId = (_e = sourceConfig.sessionId) !== null && _e !== void 0 ? _e : MKUtils_1.MKUtils.getUUID();
30
- this.baseUrl = (_g = (_f = sourceConfig.registered) === null || _f === void 0 ? void 0 : _f.environmentConfig.serverUrl) !== null && _g !== void 0 ? _g : "";
31
- this.headers = this.getRequestHeaders(sourceConfig);
32
- this.isLive = (_h = (sourceConfig.assetType === enums_1.MKAssetType.Live || sourceConfig.assetType === enums_1.MKAssetType.Event)) !== null && _h !== void 0 ? _h : false;
33
- this.rightsMode = this.isLive ? enums_1.MKRightsMode.Live : enums_1.MKRightsMode.VOD;
34
- this.adobePrimetimeConfig = (_j = sourceConfig.registered) === null || _j === void 0 ? void 0 : _j.adobePrimetimeConfig;
35
- this.isDvrFromRollingBuffer = (_l = (_k = sourceConfig.registered) === null || _k === void 0 ? void 0 : _k.isDvrFromRollingBuffer) !== null && _l !== void 0 ? _l : false;
36
- this.startTime = !!((_m = sourceConfig.registered) === null || _m === void 0 ? void 0 : _m.startTime) && (sourceConfig.assetType === enums_1.MKAssetType.Catchup || (sourceConfig.assetType === enums_1.MKAssetType.DVR && this.isDvrFromRollingBuffer)) ? sourceConfig.registered.startTime : undefined;
55
+ var MKUtils_1 = require("../common/MKUtils");
56
+ var MKHttpRequest_1 = require("./MKHttpRequest");
57
+ var enums_1 = require("../../enums");
58
+ var error_1 = require("../error");
59
+ var constants_1 = require("../../constants");
60
+ var common_1 = require("../common");
61
+ var MKAzukiRequest = exports.MKAzukiRequest = (function (_super) {
62
+ __extends(MKAzukiRequest, _super);
63
+ function MKAzukiRequest(sourceConfig, errorCallback) {
64
+ var _this = this;
65
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
66
+ _this = _super.call(this) || this;
67
+ _this.sessionManager = "azuki";
68
+ _this.isPaused = false;
69
+ _this.beaconInterval = 0;
70
+ _this.errorCallback = errorCallback;
71
+ _this.localStorage = common_1.MKLocalStorage.getInstance();
72
+ _this.mediaId = (_b = (_a = sourceConfig.registered) === null || _a === void 0 ? void 0 : _a.mediaId) !== null && _b !== void 0 ? _b : "";
73
+ _this.ownerUid = (_d = (_c = sourceConfig.registered) === null || _c === void 0 ? void 0 : _c.environmentConfig.ownerUid) !== null && _d !== void 0 ? _d : constants_1.MKConstants.AzukiDefaultOwnerUid;
74
+ _this.sessionId = (_e = sourceConfig.sessionId) !== null && _e !== void 0 ? _e : MKUtils_1.MKUtils.getUUID();
75
+ _this.offerId = (_f = sourceConfig.registered) === null || _f === void 0 ? void 0 : _f.offerId;
76
+ _this.isDvrFromRollingBuffer = (_h = (_g = sourceConfig.registered) === null || _g === void 0 ? void 0 : _g.isDvrFromRollingBuffer) !== null && _h !== void 0 ? _h : false;
77
+ _this.baseUrl = (_k = (_j = sourceConfig.registered) === null || _j === void 0 ? void 0 : _j.environmentConfig.serverUrl) !== null && _k !== void 0 ? _k : "";
78
+ _this.headers = _this.getRequestHeaders(sourceConfig);
79
+ _this.isLive = (_l = (sourceConfig.assetType === enums_1.MKAssetType.Live || sourceConfig.assetType === enums_1.MKAssetType.Event)) !== null && _l !== void 0 ? _l : false;
80
+ _this.rightsMode = _this.isLive ? enums_1.MKRightsMode.Live : enums_1.MKRightsMode.VOD;
81
+ _this.adobePrimetimeConfig = (_m = sourceConfig.registered) === null || _m === void 0 ? void 0 : _m.adobePrimetimeConfig;
82
+ _this.startTime = !!((_o = sourceConfig.registered) === null || _o === void 0 ? void 0 : _o.startTime) && (sourceConfig.assetType === enums_1.MKAssetType.Catchup || (sourceConfig.assetType === enums_1.MKAssetType.DVR && _this.isDvrFromRollingBuffer)) ? sourceConfig.registered.startTime : undefined;
83
+ return _this;
37
84
  }
38
- updateAuthToken(authToken) {
85
+ MKAzukiRequest.prototype.updateAuthToken = function (authToken) {
39
86
  if (!!authToken) {
40
87
  this.headers["AuthorizationToken"] = authToken;
41
88
  }
42
- }
43
- getBeaconInterval() {
89
+ };
90
+ MKAzukiRequest.prototype.getBeaconInterval = function () {
44
91
  return this.beaconInterval;
45
- }
46
- getBeaconData() {
92
+ };
93
+ MKAzukiRequest.prototype.getBeaconData = function () {
47
94
  return this.localStorage.getBeaconData();
48
- }
49
- registrationRequest() {
50
- return __awaiter(this, void 0, void 0, function* () {
51
- if (!!!this.headers["DeviceProfile"]) {
52
- const deviceProfile = yield common_1.MKPlatform.getDeviceProfile();
53
- if (!!deviceProfile)
54
- this.headers["DeviceProfile"] = deviceProfile;
55
- }
56
- return new Promise((resolve, reject) => {
57
- this.post(constants_1.MKAzukiRequestEndpoint.REGISTRATION.get(this.baseUrl), {
58
- headers: this.headers,
59
- queryParams: {
60
- ownerUid: this.ownerUid
61
- }
62
- })
63
- .then((response) => {
64
- MKAzukiRequest.responseTime.registration = response.responseTime;
65
- if (response.status === 200 || (response.status >= 466 && response.status < 500)) {
66
- return response.json();
67
- }
68
- return reject(new error_1.MKAzukiRequestError(constants_1.MKAzukiRequestEndpoint.REGISTRATION.API, response.status));
69
- })
70
- .then((data) => {
71
- if (data.result === "success") {
72
- return resolve();
73
- }
74
- return reject(new error_1.MKAzukiRequestError(constants_1.MKAzukiRequestEndpoint.REGISTRATION.API, data.response.code, data.response.message));
75
- })
76
- .catch((error) => {
77
- if (error instanceof error_1.MKHttpError) {
78
- return reject(new error_1.MKAzukiRequestError(constants_1.MKAzukiRequestEndpoint.REGISTRATION.API, Number(error.code), error.message));
79
- }
80
- common_1.MKLog.error("[registrationRequest] ", error);
81
- return reject(new error_1.MKAzukiRequestError(constants_1.MKAzukiRequestEndpoint.REGISTRATION.API));
82
- });
95
+ };
96
+ MKAzukiRequest.prototype.getAdobeData = function () {
97
+ return this.adobePrimetimeConfig;
98
+ };
99
+ MKAzukiRequest.prototype.setAnalyticsDataCallback = function (callback) {
100
+ this.analyticsDataCallback = callback;
101
+ };
102
+ MKAzukiRequest.prototype.registrationRequest = function () {
103
+ return __awaiter(this, void 0, void 0, function () {
104
+ var deviceProfile;
105
+ var _this = this;
106
+ return __generator(this, function (_a) {
107
+ switch (_a.label) {
108
+ case 0:
109
+ if (!!!!this.headers["DeviceProfile"]) return [3, 2];
110
+ return [4, common_1.MKPlatform.getDeviceProfile()];
111
+ case 1:
112
+ deviceProfile = _a.sent();
113
+ if (!!deviceProfile)
114
+ this.headers["DeviceProfile"] = deviceProfile;
115
+ _a.label = 2;
116
+ case 2: return [2, new Promise(function (resolve, reject) {
117
+ _this.post(constants_1.MKAzukiRequestEndpoint.REGISTRATION.get(_this.baseUrl), {
118
+ headers: _this.headers,
119
+ queryParams: {
120
+ ownerUid: _this.ownerUid
121
+ }
122
+ })
123
+ .then(function (response) {
124
+ MKAzukiRequest.responseTime.registration = response.responseTime;
125
+ if (response.status === 200 || (response.status >= 466 && response.status < 500)) {
126
+ return response.json();
127
+ }
128
+ return reject(new error_1.MKAzukiRequestError(constants_1.MKAzukiRequestEndpoint.REGISTRATION.API, response.status));
129
+ })
130
+ .then(function (data) {
131
+ if (data.result === "success") {
132
+ return resolve();
133
+ }
134
+ return reject(new error_1.MKAzukiRequestError(constants_1.MKAzukiRequestEndpoint.REGISTRATION.API, data.response.code, data.response.message));
135
+ })
136
+ .catch(function (error) {
137
+ if (error instanceof error_1.MKHttpError) {
138
+ return reject(new error_1.MKAzukiRequestError(constants_1.MKAzukiRequestEndpoint.REGISTRATION.API, Number(error.code), error.message));
139
+ }
140
+ common_1.MKLog.error("[registrationRequest] ", error);
141
+ return reject(new error_1.MKAzukiRequestError(constants_1.MKAzukiRequestEndpoint.REGISTRATION.API));
142
+ });
143
+ })];
144
+ }
83
145
  });
84
146
  });
85
- }
86
- rollRequest() {
87
- return __awaiter(this, void 0, void 0, function* () {
88
- const savedAuthToken = this.localStorage.getRegistered();
89
- const currentAuthToken = this.headers["AuthorizationToken"];
90
- if (currentAuthToken && currentAuthToken !== savedAuthToken) {
91
- this.localStorage.clearRegistered();
92
- try {
93
- yield this.registrationRequest();
94
- this.localStorage.setRegistered(currentAuthToken);
95
- }
96
- catch (error) {
97
- return Promise.reject(error);
98
- }
99
- }
100
- if (!!!this.headers["DeviceProfile"]) {
101
- const deviceProfile = yield common_1.MKPlatform.getDeviceProfile();
102
- if (!!deviceProfile)
103
- this.headers["DeviceProfile"] = deviceProfile;
104
- }
105
- yield this.pendingBeaconRequest();
106
- const queryParams = {
107
- mediaId: this.mediaId,
108
- ownerUid: this.ownerUid,
109
- sessionId: this.sessionId
110
- };
111
- if (this.isDvrFromRollingBuffer) {
112
- queryParams["is_dvr"] = this.isDvrFromRollingBuffer;
113
- }
114
- else {
115
- delete queryParams["is_dvr"];
116
- }
117
- return new Promise((resolve, reject) => {
118
- this.post(constants_1.MKAzukiRequestEndpoint.ROLL.get(this.baseUrl), {
119
- headers: this.headers,
120
- queryParams: queryParams,
121
- body: {
122
- roll: {
123
- isLive: this.isLive,
124
- rightsMode: this.rightsMode,
125
- startTime: this.startTime,
126
- locationDetail: MKAzukiRequest.locationDetail,
127
- adobePrimeTimeConfig: this.adobePrimetimeConfig,
128
- inhome: MKAzukiRequest.inhomeStatus ? "yes" : "no"
147
+ };
148
+ MKAzukiRequest.prototype.rollRequest = function () {
149
+ return __awaiter(this, void 0, void 0, function () {
150
+ var savedAuthToken, currentAuthToken, error_2, deviceProfile, queryParams;
151
+ var _this = this;
152
+ return __generator(this, function (_a) {
153
+ switch (_a.label) {
154
+ case 0:
155
+ savedAuthToken = this.localStorage.getRegistered();
156
+ currentAuthToken = this.headers["AuthorizationToken"];
157
+ if (!(currentAuthToken && currentAuthToken !== savedAuthToken)) return [3, 4];
158
+ this.localStorage.clearRegistered();
159
+ _a.label = 1;
160
+ case 1:
161
+ _a.trys.push([1, 3, , 4]);
162
+ return [4, this.registrationRequest()];
163
+ case 2:
164
+ _a.sent();
165
+ this.localStorage.setRegistered(currentAuthToken);
166
+ return [3, 4];
167
+ case 3:
168
+ error_2 = _a.sent();
169
+ return [2, Promise.reject(error_2)];
170
+ case 4:
171
+ if (!!!!this.headers["DeviceProfile"]) return [3, 6];
172
+ return [4, common_1.MKPlatform.getDeviceProfile()];
173
+ case 5:
174
+ deviceProfile = _a.sent();
175
+ if (!!deviceProfile)
176
+ this.headers["DeviceProfile"] = deviceProfile;
177
+ _a.label = 6;
178
+ case 6: return [4, this.pendingBeaconRequest()];
179
+ case 7:
180
+ _a.sent();
181
+ queryParams = {
182
+ mediaId: this.mediaId,
183
+ ownerUid: this.ownerUid,
184
+ sessionId: this.sessionId
185
+ };
186
+ if (!!this.offerId)
187
+ queryParams["oid"] = this.offerId;
188
+ if (this.isDvrFromRollingBuffer) {
189
+ queryParams["is_dvr"] = this.isDvrFromRollingBuffer;
129
190
  }
130
- }
131
- })
132
- .then((response) => {
133
- MKAzukiRequest.responseTime.roll = response.responseTime;
134
- if (response.status === 200 || (response.status >= 466 && response.status < 500)) {
135
- return response.json();
136
- }
137
- return reject(new error_1.MKAzukiRequestError(constants_1.MKAzukiRequestEndpoint.ROLL.API, response.status));
138
- })
139
- .then((data) => {
140
- if (data.result === "success") {
141
- const rollInfo = common_1.MKAzukiResponseUtils.getRollInfo(data.response, this.baseUrl, queryParams, this.headers);
142
- this.beaconInterval = rollInfo.beaconInterval;
143
- rollInfo.beaconInterval > 0 ? this.saveBeaconData() : this.clearBeaconData();
144
- return resolve(rollInfo);
145
- }
146
- return reject(new error_1.MKAzukiRequestError(constants_1.MKAzukiRequestEndpoint.ROLL.API, data.response.code, data.response.message));
147
- })
148
- .catch((error) => {
149
- if (error instanceof error_1.MKHttpError) {
150
- return reject(new error_1.MKAzukiRequestError(constants_1.MKAzukiRequestEndpoint.ROLL.API, Number(error.code), error.message));
151
- }
152
- common_1.MKLog.error("[rollRequest] ", error);
153
- return reject(new error_1.MKAzukiRequestError(constants_1.MKAzukiRequestEndpoint.ROLL.API));
154
- });
191
+ else {
192
+ delete queryParams["is_dvr"];
193
+ }
194
+ return [2, new Promise(function (resolve, reject) {
195
+ _this.post(constants_1.MKAzukiRequestEndpoint.ROLL.get(_this.baseUrl), {
196
+ headers: _this.headers,
197
+ queryParams: queryParams,
198
+ body: {
199
+ roll: {
200
+ isLive: _this.isLive,
201
+ rightsMode: _this.rightsMode,
202
+ startTime: _this.startTime,
203
+ locationDetail: MKAzukiRequest.locationDetail,
204
+ adobePrimeTimeConfig: _this.adobePrimetimeConfig,
205
+ inhome: MKAzukiRequest.inhomeStatus ? "yes" : "no"
206
+ }
207
+ }
208
+ })
209
+ .then(function (response) {
210
+ MKAzukiRequest.responseTime.roll = response.responseTime;
211
+ if (response.status === 200 || (response.status >= 466 && response.status < 500)) {
212
+ return response.json();
213
+ }
214
+ return reject(new error_1.MKAzukiRequestError(constants_1.MKAzukiRequestEndpoint.ROLL.API, response.status));
215
+ })
216
+ .then(function (data) {
217
+ if (data.result === "success") {
218
+ var rollInfo = common_1.MKAzukiResponseUtils.getRollInfo(data.response, _this.baseUrl, queryParams, _this.headers);
219
+ _this.beaconInterval = rollInfo.beaconInterval;
220
+ rollInfo.beaconInterval > 0 ? _this.saveBeaconData() : _this.clearBeaconData();
221
+ return resolve(rollInfo);
222
+ }
223
+ return reject(new error_1.MKAzukiRequestError(constants_1.MKAzukiRequestEndpoint.ROLL.API, data.response.code, data.response.message));
224
+ })
225
+ .catch(function (error) {
226
+ if (error instanceof error_1.MKHttpError) {
227
+ return reject(new error_1.MKAzukiRequestError(constants_1.MKAzukiRequestEndpoint.ROLL.API, Number(error.code), error.message));
228
+ }
229
+ common_1.MKLog.error("[rollRequest] ", error);
230
+ return reject(new error_1.MKAzukiRequestError(constants_1.MKAzukiRequestEndpoint.ROLL.API));
231
+ });
232
+ })];
233
+ }
155
234
  });
156
235
  });
157
- }
158
- programInfoRequest(startDate, endDate) {
159
- return __awaiter(this, void 0, void 0, function* () {
160
- return new Promise((resolve, _reject) => {
161
- this.get(constants_1.MKAzukiRequestEndpoint.QUERY.get(this.baseUrl), {
162
- queryParams: {
163
- channelId: this.mediaId,
164
- ownerUid: this.ownerUid,
165
- startDate: startDate,
166
- endDate: endDate,
167
- pbr: true,
168
- programs: true,
169
- partialPrograms: true,
170
- externalRecordings: false
171
- },
172
- headers: this.headers
173
- })
174
- .then((response) => {
175
- MKAzukiRequest.responseTime.query = response.responseTime;
176
- if (response.ok) {
177
- return response.json();
178
- }
179
- return resolve([]);
180
- })
181
- .then((data) => {
182
- const programInfoList = [];
183
- if (data.result === "success" && MKUtils_1.MKUtils.isArray(data.response.medias)) {
184
- const programs = data.response.medias;
185
- programs.forEach((program) => {
186
- programInfoList.push(common_1.MKAzukiResponseUtils.getProgramInfo(program));
236
+ };
237
+ MKAzukiRequest.prototype.programInfoRequest = function (startDate, endDate) {
238
+ return __awaiter(this, void 0, void 0, function () {
239
+ var _this = this;
240
+ return __generator(this, function (_a) {
241
+ return [2, new Promise(function (resolve, _reject) {
242
+ _this.get(constants_1.MKAzukiRequestEndpoint.QUERY.get(_this.baseUrl), {
243
+ queryParams: {
244
+ channelId: _this.mediaId,
245
+ ownerUid: _this.ownerUid,
246
+ startDate: startDate,
247
+ endDate: endDate,
248
+ pbr: true,
249
+ programs: true,
250
+ partialPrograms: true,
251
+ externalRecordings: false
252
+ },
253
+ headers: _this.headers
254
+ })
255
+ .then(function (response) {
256
+ MKAzukiRequest.responseTime.query = response.responseTime;
257
+ if (response.ok) {
258
+ return response.json();
259
+ }
260
+ return resolve([]);
261
+ })
262
+ .then(function (data) {
263
+ var programInfoList = [];
264
+ if (data.result === "success" && MKUtils_1.MKUtils.isArray(data.response.medias)) {
265
+ var programs = data.response.medias;
266
+ programs.forEach(function (program) {
267
+ programInfoList.push(common_1.MKAzukiResponseUtils.getProgramInfo(program));
268
+ });
269
+ }
270
+ return resolve(programInfoList);
271
+ })
272
+ .catch(function () {
273
+ return resolve([]);
187
274
  });
188
- }
189
- return resolve(programInfoList);
190
- })
191
- .catch(() => {
192
- return resolve([]);
193
- });
275
+ })];
194
276
  });
195
277
  });
196
- }
197
- startSession() {
198
- return __awaiter(this, void 0, void 0, function* () {
199
- if (this.beaconInterval === 0)
200
- return;
201
- return this.beaconRequest()
202
- .then(() => {
203
- this.scheduleBeaconRequest(this.beaconInterval * 1000);
278
+ };
279
+ MKAzukiRequest.prototype.startSession = function () {
280
+ return __awaiter(this, void 0, void 0, function () {
281
+ var _this = this;
282
+ return __generator(this, function (_a) {
283
+ if (this.beaconInterval === 0)
284
+ return [2];
285
+ this.isPaused = false;
286
+ return [2, this.beaconRequest()
287
+ .then(function () {
288
+ _this.scheduleBeaconRequest(_this.beaconInterval * 1000);
289
+ })];
204
290
  });
205
291
  });
206
- }
207
- stopSession() {
208
- return __awaiter(this, void 0, void 0, function* () {
209
- if (this.beaconInterval === 0)
210
- return;
211
- clearInterval(this.beaconTimer);
212
- return this.beaconRequest(true);
292
+ };
293
+ MKAzukiRequest.prototype.stopSession = function () {
294
+ return __awaiter(this, void 0, void 0, function () {
295
+ return __generator(this, function (_a) {
296
+ if (this.beaconInterval === 0)
297
+ return [2];
298
+ clearInterval(this.beaconTimer);
299
+ return [2, this.beaconRequest(true)];
300
+ });
213
301
  });
214
- }
215
- scheduleBeaconRequest(interval) {
302
+ };
303
+ MKAzukiRequest.prototype.PauseSession = function () {
304
+ this.isPaused = true;
305
+ if (this.beaconInterval === 0)
306
+ return;
307
+ clearInterval(this.beaconTimer);
308
+ };
309
+ MKAzukiRequest.prototype.scheduleBeaconRequest = function (interval) {
310
+ var _this = this;
216
311
  if (this.beaconTimer)
217
312
  clearInterval(this.beaconTimer);
218
- this.beaconTimer = setInterval(() => {
219
- this.beaconRequest()
220
- .catch((error) => {
221
- if (this.errorCallback)
222
- this.errorCallback(error);
313
+ this.beaconTimer = setInterval(function () {
314
+ _this.beaconRequest()
315
+ .catch(function (error) {
316
+ if (_this.errorCallback)
317
+ _this.errorCallback(error);
223
318
  });
224
319
  }, interval);
225
- }
226
- beaconRequest(isFinalBeacon = false) {
227
- return __awaiter(this, void 0, void 0, function* () {
228
- return new Promise((resolve, reject) => {
229
- this.post(constants_1.MKAzukiRequestEndpoint.BEACONS.get(this.baseUrl), {
230
- body: {
231
- beacon: {
232
- isLive: this.isLive,
233
- complete: isFinalBeacon,
234
- inhome: MKAzukiRequest.inhomeStatus ? "yes" : "no"
235
- }
236
- },
237
- queryParams: {
238
- mediaId: this.mediaId,
239
- ownerUid: this.ownerUid,
240
- sessionId: this.sessionId
241
- },
242
- headers: this.headers
243
- })
244
- .then((response) => {
245
- MKAzukiRequest.responseTime.beacons = response.responseTime;
246
- if (response.status === 200 || (response.status >= 466 && response.status < 500)) {
247
- return response.json();
248
- }
249
- return reject(new error_1.MKAzukiRequestError(constants_1.MKAzukiRequestEndpoint.BEACONS.API, response.status));
250
- })
251
- .then((data) => {
252
- var _a;
253
- if (data.result === "success") {
254
- const beaconResponse = data.response;
255
- const beaconInterval = (_a = beaconResponse.interval) !== null && _a !== void 0 ? _a : 0;
256
- if (isFinalBeacon && beaconInterval === 0) {
257
- this.clearBeaconData();
258
- }
259
- return resolve();
260
- }
261
- return reject(new error_1.MKAzukiRequestError(constants_1.MKAzukiRequestEndpoint.BEACONS.API, data.response.code, data.response.message));
262
- })
263
- .catch((error) => {
264
- if (error instanceof error_1.MKHttpError) {
265
- return reject(new error_1.MKAzukiRequestError(constants_1.MKAzukiRequestEndpoint.BEACONS.API, Number(error.code), error.message));
266
- }
267
- common_1.MKLog.error("[beaconRequest] ", error);
268
- return reject(new error_1.MKAzukiRequestError(constants_1.MKAzukiRequestEndpoint.BEACONS.API));
269
- });
320
+ };
321
+ MKAzukiRequest.prototype.beaconRequest = function (isFinalBeacon) {
322
+ if (isFinalBeacon === void 0) { isFinalBeacon = false; }
323
+ return __awaiter(this, void 0, void 0, function () {
324
+ var _this = this;
325
+ return __generator(this, function (_a) {
326
+ return [2, new Promise(function (resolve, reject) {
327
+ _this.post(constants_1.MKAzukiRequestEndpoint.BEACONS.get(_this.baseUrl), {
328
+ body: {
329
+ beacon: {
330
+ isLive: _this.isLive,
331
+ complete: isFinalBeacon,
332
+ inhome: MKAzukiRequest.inhomeStatus ? "yes" : "no"
333
+ }
334
+ },
335
+ queryParams: {
336
+ mediaId: _this.mediaId,
337
+ ownerUid: _this.ownerUid,
338
+ sessionId: _this.sessionId
339
+ },
340
+ headers: _this.headers
341
+ })
342
+ .then(function (response) {
343
+ MKAzukiRequest.responseTime.beacons = response.responseTime;
344
+ if (!!_this.analyticsDataCallback) {
345
+ _this.analyticsDataCallback(enums_1.MKAnalyticsDataName.LastBeacon, response.responseTime);
346
+ }
347
+ if (response.status === 200 || (response.status >= 466 && response.status < 500)) {
348
+ return response.json();
349
+ }
350
+ return reject(new error_1.MKAzukiRequestError(constants_1.MKAzukiRequestEndpoint.BEACONS.API, response.status));
351
+ })
352
+ .then(function (data) {
353
+ var _a;
354
+ if (data.result === "success") {
355
+ var beaconResponse = data.response;
356
+ var beaconInterval = (_a = beaconResponse.interval) !== null && _a !== void 0 ? _a : 0;
357
+ if (isFinalBeacon && beaconInterval === 0) {
358
+ _this.clearBeaconData();
359
+ }
360
+ return resolve();
361
+ }
362
+ return reject(new error_1.MKAzukiRequestError(constants_1.MKAzukiRequestEndpoint.BEACONS.API, data.response.code, data.response.message));
363
+ })
364
+ .catch(function (error) {
365
+ if (error instanceof error_1.MKHttpError) {
366
+ return reject(new error_1.MKAzukiRequestError(constants_1.MKAzukiRequestEndpoint.BEACONS.API, Number(error.code), error.message));
367
+ }
368
+ common_1.MKLog.error("[beaconRequest] ", error);
369
+ return reject(new error_1.MKAzukiRequestError(constants_1.MKAzukiRequestEndpoint.BEACONS.API));
370
+ });
371
+ })];
270
372
  });
271
373
  });
272
- }
273
- pendingBeaconRequest() {
274
- return __awaiter(this, void 0, void 0, function* () {
275
- const beaconData = this.localStorage.getBeaconData();
276
- if (beaconData && !!beaconData.requestUrl && beaconData.requestOptions) {
277
- try {
278
- const response = yield this.post(beaconData.requestUrl, beaconData.requestOptions);
279
- common_1.MKLog.debug("Pending beacon notification ", response.ok ? "successful." : "failed.");
280
- this.clearBeaconData();
281
- }
282
- catch (error) {
283
- common_1.MKLog.debug("Pending beacon notification failed with error: ", error);
284
- this.clearBeaconData();
374
+ };
375
+ MKAzukiRequest.prototype.pendingBeaconRequest = function () {
376
+ return __awaiter(this, void 0, void 0, function () {
377
+ var beaconData, response, error_3;
378
+ return __generator(this, function (_a) {
379
+ switch (_a.label) {
380
+ case 0:
381
+ beaconData = this.localStorage.getBeaconData();
382
+ if (!(beaconData && !!beaconData.requestUrl && beaconData.requestOptions)) return [3, 4];
383
+ _a.label = 1;
384
+ case 1:
385
+ _a.trys.push([1, 3, , 4]);
386
+ return [4, this.post(beaconData.requestUrl, beaconData.requestOptions)];
387
+ case 2:
388
+ response = _a.sent();
389
+ common_1.MKLog.debug("Pending beacon notification ", response.ok ? "successful." : "failed.");
390
+ this.clearBeaconData();
391
+ return [3, 4];
392
+ case 3:
393
+ error_3 = _a.sent();
394
+ common_1.MKLog.debug("Pending beacon notification failed with error: ", error_3);
395
+ this.clearBeaconData();
396
+ return [3, 4];
397
+ case 4: return [2];
285
398
  }
286
- }
399
+ });
287
400
  });
288
- }
289
- getRequestHeaders(sourceConfig) {
290
- const requestHeaders = {};
401
+ };
402
+ MKAzukiRequest.prototype.getRequestHeaders = function (sourceConfig) {
403
+ var requestHeaders = {};
291
404
  if (sourceConfig.registered) {
292
405
  requestHeaders["AzukiIMC"] = constants_1.MKConstants.AzukiIMC;
293
406
  requestHeaders["Content-Type"] = "application/json";
@@ -300,9 +413,9 @@ class MKAzukiRequest extends MKHttpRequest_1.MKHttpRequest {
300
413
  }
301
414
  }
302
415
  return requestHeaders;
303
- }
304
- saveBeaconData() {
305
- const beaconData = {
416
+ };
417
+ MKAzukiRequest.prototype.saveBeaconData = function () {
418
+ var beaconData = {
306
419
  requestUrl: constants_1.MKAzukiRequestEndpoint.BEACONS.get(this.baseUrl),
307
420
  requestOptions: {
308
421
  body: {
@@ -321,17 +434,17 @@ class MKAzukiRequest extends MKHttpRequest_1.MKHttpRequest {
321
434
  }
322
435
  };
323
436
  this.localStorage.setBeaconData(beaconData);
324
- }
325
- clearBeaconData() {
437
+ };
438
+ MKAzukiRequest.prototype.clearBeaconData = function () {
326
439
  this.localStorage.clearBeaconData();
327
- }
328
- }
329
- exports.MKAzukiRequest = MKAzukiRequest;
330
- MKAzukiRequest.inhomeStatus = false;
331
- MKAzukiRequest.responseTime = {
332
- registration: 0,
333
- roll: 0,
334
- beacons: 0,
335
- query: 0
336
- };
440
+ };
441
+ MKAzukiRequest.inhomeStatus = false;
442
+ MKAzukiRequest.responseTime = {
443
+ registration: 0,
444
+ roll: 0,
445
+ beacons: 0,
446
+ query: 0
447
+ };
448
+ return MKAzukiRequest;
449
+ }(MKHttpRequest_1.MKHttpRequest));
337
450
  //# sourceMappingURL=MKAzukiRequest.js.map