@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.
- package/mkplayer.js +1 -1
- package/package.json +2 -2
- package/types/alias/index.d.ts +1 -1
- package/types/classes/common/MKAzukiResponseUtils.js +66 -58
- package/types/classes/common/MKAzukiResponseUtils.js.map +1 -1
- package/types/classes/common/MKEventBase.js +11 -10
- package/types/classes/common/MKEventBase.js.map +1 -1
- package/types/classes/common/MKLocalStorage.js +64 -58
- package/types/classes/common/MKLocalStorage.js.map +1 -1
- package/types/classes/common/MKLog.js +49 -22
- package/types/classes/common/MKLog.js.map +1 -1
- package/types/classes/common/MKPlatform.js +156 -108
- package/types/classes/common/MKPlatform.js.map +1 -1
- package/types/classes/common/MKProgramManager.js +37 -32
- package/types/classes/common/MKProgramManager.js.map +1 -1
- package/types/classes/common/MKSecureUrlManager.js +137 -108
- package/types/classes/common/MKSecureUrlManager.js.map +1 -1
- package/types/classes/common/MKSubtitleOverlay.js +69 -67
- package/types/classes/common/MKSubtitleOverlay.js.map +1 -1
- package/types/classes/common/MKThumbnailManager.js +261 -211
- package/types/classes/common/MKThumbnailManager.js.map +1 -1
- package/types/classes/common/MKUtils.js +162 -100
- package/types/classes/common/MKUtils.js.map +1 -1
- package/types/classes/error/MKAdobeSessionConcurrencyError.js +6 -5
- package/types/classes/error/MKAdobeSessionConcurrencyError.js.map +1 -1
- package/types/classes/error/MKAzukiRequestError.js +8 -7
- package/types/classes/error/MKAzukiRequestError.js.map +1 -1
- package/types/classes/error/MKBitmovinPlayerError.js +31 -12
- package/types/classes/error/MKBitmovinPlayerError.js.map +1 -1
- package/types/classes/error/MKHttpError.js +4 -3
- package/types/classes/error/MKHttpError.js.map +1 -1
- package/types/classes/error/MKPlayerError.js +5 -4
- package/types/classes/error/MKPlayerError.js.map +1 -1
- package/types/classes/error/MKProgramRestrictionError.js +11 -10
- package/types/classes/error/MKProgramRestrictionError.js.map +1 -1
- package/types/classes/player/MKBitmovinPlayer.js +620 -553
- package/types/classes/player/MKBitmovinPlayer.js.map +1 -1
- package/types/classes/player/MKPlayer.d.ts +4 -0
- package/types/classes/player/MKPlayer.js +734 -528
- package/types/classes/player/MKPlayer.js.map +1 -1
- package/types/classes/player/MKStubPlayer.js +263 -273
- package/types/classes/player/MKStubPlayer.js.map +1 -1
- package/types/classes/request/MKAdobeSessionConcurrencyRequest.js +198 -127
- package/types/classes/request/MKAdobeSessionConcurrencyRequest.js.map +1 -1
- package/types/classes/request/MKAzukiRequest.js +381 -268
- package/types/classes/request/MKAzukiRequest.js.map +1 -1
- package/types/classes/request/MKHttpRequest.js +128 -89
- package/types/classes/request/MKHttpRequest.js.map +1 -1
- package/types/constants/MKAzukiRequestEndpoint.js +24 -24
- package/types/constants/MKAzukiRequestEndpoint.js.map +1 -1
- package/types/constants/MKConstants.js +1 -1
- package/types/enums/MKAnalyticsDataName.d.ts +8 -0
- package/types/enums/MKAnalyticsDataName.js +13 -0
- package/types/enums/MKAnalyticsDataName.js.map +1 -0
- package/types/enums/MKErrorCode.d.ts +1 -0
- package/types/enums/MKErrorCode.js +1 -0
- package/types/enums/MKErrorCode.js.map +1 -1
- package/types/enums/MKPlayerEvent.d.ts +6 -1
- package/types/enums/MKPlayerEvent.js +5 -0
- package/types/enums/MKPlayerEvent.js.map +1 -1
- package/types/enums/MKProgramRestrictionType.js.map +1 -1
- package/types/enums/index.d.ts +1 -0
- package/types/enums/index.js +3 -1
- package/types/enums/index.js.map +1 -1
- package/types/interfaces/MKAdaptationPlatformConfig.js +1 -1
- package/types/interfaces/MKAdaptationPlatformConfig.js.map +1 -1
- package/types/interfaces/MKBufferConfig.js +1 -1
- package/types/interfaces/MKBufferConfig.js.map +1 -1
- package/types/interfaces/MKBufferMediaTypeConfig.js +1 -1
- package/types/interfaces/MKBufferMediaTypeConfig.js.map +1 -1
- package/types/interfaces/MKDrmConfig.js +1 -1
- package/types/interfaces/MKDrmConfig.js.map +1 -1
- package/types/interfaces/MKRegisteredSource.d.ts +1 -0
- package/types/interfaces/events/MKAnalyticsDataEvent.d.ts +6 -0
- package/types/interfaces/events/MKAnalyticsDataEvent.js +3 -0
- package/types/interfaces/events/MKAnalyticsDataEvent.js.map +1 -0
- package/types/interfaces/events/MKAudioPlaybackQualityChangedEvent.d.ts +2 -1
- package/types/interfaces/events/MKMediaPlaybackQualityChangeEvent.d.ts +3 -3
- package/types/interfaces/events/MKVSPPSessionIdEvent.d.ts +4 -0
- package/types/interfaces/events/MKVSPPSessionIdEvent.js +3 -0
- package/types/interfaces/events/MKVSPPSessionIdEvent.js.map +1 -0
- package/types/interfaces/events/MKVideoPlaybackQualityChangedEvent.d.ts +2 -1
- package/types/interfaces/events/index.d.ts +2 -0
- package/types/src/alias/index.d.ts +1 -1
- package/types/src/classes/player/MKPlayer.d.ts +4 -0
- package/types/src/enums/MKAnalyticsDataName.d.ts +8 -0
- package/types/src/enums/MKErrorCode.d.ts +1 -0
- package/types/src/enums/MKPlayerEvent.d.ts +6 -1
- package/types/src/enums/index.d.ts +1 -0
- package/types/src/interfaces/MKRegisteredSource.d.ts +1 -0
- package/types/src/interfaces/events/MKAnalyticsDataEvent.d.ts +6 -0
- package/types/src/interfaces/events/MKAudioPlaybackQualityChangedEvent.d.ts +2 -1
- package/types/src/interfaces/events/MKMediaPlaybackQualityChangeEvent.d.ts +3 -3
- package/types/src/interfaces/events/MKVSPPSessionIdEvent.d.ts +4 -0
- package/types/src/interfaces/events/MKVideoPlaybackQualityChangedEvent.d.ts +2 -1
- package/types/src/interfaces/events/index.d.ts +2 -0
- package/types/plugins/fmts/MKFMTSConfig.d.ts +0 -10
- package/types/plugins/fmts/MKFMTSController.d.ts +0 -39
- package/types/plugins/fmts/MKFMTSUtils.d.ts +0 -4
- package/types/plugins/fmts/index.d.ts +0 -2
- package/types/plugins/omsdk/MKOMSDKConfig.d.ts +0 -6
- package/types/plugins/omsdk/MKOMSDKConstants.d.ts +0 -152
- package/types/plugins/omsdk/MKOMSDKController.d.ts +0 -58
- 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
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
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
|
-
|
|
50
|
-
return
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
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
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
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
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
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
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
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
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
this.
|
|
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
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
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
|
-
|
|
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
|
-
|
|
220
|
-
.catch((error)
|
|
221
|
-
if (
|
|
222
|
-
|
|
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
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
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
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
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
|