@smoud/playable-sdk 1.0.12 → 1.0.14
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/README.md +3 -2
- package/defines.d.ts +1 -0
- package/dist/esm/index.js +42 -19
- package/dist/iife/index.js +42 -19
- package/dist/index.js +42 -19
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -377,8 +377,9 @@ Get started quickly with our template projects:
|
|
|
377
377
|
#### MRAID Networks
|
|
378
378
|
|
|
379
379
|
- [MRAID 3.0](https://www.iab.com/wp-content/uploads/2017/07/MRAID_3.0_FINAL.pdf)
|
|
380
|
-
- [IronSource - MRAID requirements](https://developers.is.com/ironsource-mobile/general/mraid-requirements/#step-1)
|
|
381
380
|
- [IronSource - Interactive ad creative requirements](https://developers.is.com/ironsource-mobile/general/interactive-requirements/#step-1)
|
|
381
|
+
- [IronSource - MRAID requirements](https://developers.is.com/ironsource-mobile/general/mraid-requirements/#step-1)
|
|
382
|
+
- [IronSource - DAPI requirements](https://developers.is.com/ironsource-mobile/general/dapi-requirements/#step-1)
|
|
382
383
|
- [Unity Ads Documentation](https://docs.unity.com/acquire/en-us/manual/playable-ads-specifications)
|
|
383
384
|
- [Chartboost Integration](https://docs.chartboost.com/en/advertising/creatives/creative-assets/)
|
|
384
385
|
|
|
@@ -397,7 +398,7 @@ Get started quickly with our template projects:
|
|
|
397
398
|
- [Vungle Creative QA](https://vungle.com/creative-verifier/)
|
|
398
399
|
- [Facebook Playable Preview Tool](https://developers.facebook.com/tools/playable-preview/)
|
|
399
400
|
- [Google HTML5 Validator](https://h5validator.appspot.com/adwords/asset)
|
|
400
|
-
- [IronSource
|
|
401
|
+
- [IronSource - Submit an HTML asset for review](https://developers.is.com/ironsource-mobile/general/html-upload/)
|
|
401
402
|
- [Mintegral Testing Tool](https://www.playturbo.com/review)
|
|
402
403
|
|
|
403
404
|
## Issues
|
package/defines.d.ts
CHANGED
package/dist/esm/index.js
CHANGED
|
@@ -12,7 +12,7 @@ function onEvent(event, fn, context, once) {
|
|
|
12
12
|
function offEvent(event, fn, context) {
|
|
13
13
|
const listeners = registeredEvents[event];
|
|
14
14
|
if (!listeners) return;
|
|
15
|
-
|
|
15
|
+
const fnArray = listeners.list;
|
|
16
16
|
if (!fn) {
|
|
17
17
|
fnArray.length = 0;
|
|
18
18
|
} else {
|
|
@@ -29,12 +29,12 @@ function offEvent(event, fn, context) {
|
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
31
|
function emitEvent(event, a1, a2, a3) {
|
|
32
|
-
|
|
32
|
+
const listeners = registeredEvents[event];
|
|
33
33
|
if (!listeners) return;
|
|
34
34
|
const fnArray = listeners.list;
|
|
35
35
|
const len = arguments.length;
|
|
36
36
|
let fn, ctx;
|
|
37
|
-
for (
|
|
37
|
+
for (let i = 0; i < fnArray.length; i += 3) {
|
|
38
38
|
fn = fnArray[i];
|
|
39
39
|
ctx = fnArray[i + 1];
|
|
40
40
|
if (fnArray[i + 2]) {
|
|
@@ -125,6 +125,7 @@ var isSDKInitialized = false;
|
|
|
125
125
|
var isProtocolInitialized = false;
|
|
126
126
|
var isForcePaused = false;
|
|
127
127
|
var isInstallClicked = false;
|
|
128
|
+
var actualVolume = 1;
|
|
128
129
|
var initCallback = () => {
|
|
129
130
|
};
|
|
130
131
|
function bootAd() {
|
|
@@ -137,9 +138,17 @@ function bootAd() {
|
|
|
137
138
|
emitEvent("ready");
|
|
138
139
|
sdk.isReady = true;
|
|
139
140
|
}
|
|
140
|
-
function
|
|
141
|
+
function fireVolumeChange(value) {
|
|
141
142
|
emitEvent("volume", value);
|
|
142
143
|
}
|
|
144
|
+
function changeVolume(value) {
|
|
145
|
+
sdk.volume = value;
|
|
146
|
+
fireVolumeChange(value);
|
|
147
|
+
}
|
|
148
|
+
function handleVolumeChange(value) {
|
|
149
|
+
actualVolume = value;
|
|
150
|
+
if (!sdk.isPaused) changeVolume(actualVolume);
|
|
151
|
+
}
|
|
143
152
|
function handlePause() {
|
|
144
153
|
changeVolume(0);
|
|
145
154
|
sdk.isPaused = true;
|
|
@@ -147,7 +156,7 @@ function handlePause() {
|
|
|
147
156
|
}
|
|
148
157
|
function handleResume() {
|
|
149
158
|
if (isForcePaused) return;
|
|
150
|
-
changeVolume(
|
|
159
|
+
changeVolume(actualVolume);
|
|
151
160
|
sdk.isPaused = false;
|
|
152
161
|
emitEvent("resume");
|
|
153
162
|
}
|
|
@@ -174,7 +183,7 @@ function dapiIsViewable(event) {
|
|
|
174
183
|
if (sdk.isReady) {
|
|
175
184
|
handleResume();
|
|
176
185
|
} else {
|
|
177
|
-
|
|
186
|
+
const screenSize = dapi.getScreenSize();
|
|
178
187
|
screenSize.width = Math.floor(screenSize.width);
|
|
179
188
|
screenSize.height = Math.floor(screenSize.height);
|
|
180
189
|
bootAd();
|
|
@@ -191,18 +200,26 @@ function startMraidProtocol() {
|
|
|
191
200
|
if (!isProtocolInitialized) {
|
|
192
201
|
mraid.removeEventListener("ready", startMraidProtocol);
|
|
193
202
|
mraid.addEventListener("viewableChange", function() {
|
|
194
|
-
|
|
203
|
+
const isViewable = mraid.isViewable();
|
|
195
204
|
mraidIsViewable(isViewable);
|
|
196
205
|
});
|
|
197
206
|
if (mraid.isViewable() || AD_NETWORK == "adcolony") {
|
|
198
207
|
mraidIsViewable(true);
|
|
199
208
|
}
|
|
209
|
+
if (mraid.getAudioVolume) {
|
|
210
|
+
const isAudioEnabled = mraid.getAudioVolume();
|
|
211
|
+
if (isAudioEnabled) {
|
|
212
|
+
handleVolumeChange(1);
|
|
213
|
+
} else {
|
|
214
|
+
handleVolumeChange(0);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
200
217
|
mraid.addEventListener("audioVolumeChange", function(newVolume) {
|
|
201
218
|
if (newVolume !== null) {
|
|
202
219
|
if (newVolume > 0) {
|
|
203
|
-
|
|
220
|
+
handleVolumeChange(1);
|
|
204
221
|
} else {
|
|
205
|
-
|
|
222
|
+
handleVolumeChange(0);
|
|
206
223
|
}
|
|
207
224
|
}
|
|
208
225
|
});
|
|
@@ -210,7 +227,7 @@ function startMraidProtocol() {
|
|
|
210
227
|
console.log("mraid error: " + t + " action: " + e);
|
|
211
228
|
});
|
|
212
229
|
mraid.addEventListener("sizeChange", function() {
|
|
213
|
-
|
|
230
|
+
const maxSize = mraid.getMaxSize();
|
|
214
231
|
fireResizeEvent(maxSize.width, maxSize.height);
|
|
215
232
|
});
|
|
216
233
|
isProtocolInitialized = true;
|
|
@@ -220,17 +237,22 @@ function startDapiProtocol() {
|
|
|
220
237
|
if ("dapi" !== AD_PROTOCOL) return;
|
|
221
238
|
if (!isProtocolInitialized) {
|
|
222
239
|
dapi.removeEventListener("ready", startDapiProtocol);
|
|
223
|
-
dapi.getAudioVolume();
|
|
240
|
+
const isAudioEnabled = dapi.getAudioVolume();
|
|
241
|
+
if (isAudioEnabled) {
|
|
242
|
+
handleVolumeChange(1);
|
|
243
|
+
} else {
|
|
244
|
+
handleVolumeChange(0);
|
|
245
|
+
}
|
|
224
246
|
dapi.addEventListener("audioVolumeChange", function(volume) {
|
|
225
|
-
|
|
226
|
-
if (
|
|
227
|
-
|
|
247
|
+
const isAudioEnabled2 = !!volume;
|
|
248
|
+
if (isAudioEnabled2) {
|
|
249
|
+
handleVolumeChange(1);
|
|
228
250
|
} else {
|
|
229
|
-
|
|
251
|
+
handleVolumeChange(0);
|
|
230
252
|
}
|
|
231
253
|
});
|
|
232
254
|
dapi.addEventListener("adResized", function(event) {
|
|
233
|
-
|
|
255
|
+
const maxSize = dapi.getScreenSize();
|
|
234
256
|
fireResizeEvent(event.width || maxSize.width, event.height || maxSize.height);
|
|
235
257
|
});
|
|
236
258
|
if (dapi.isViewable()) {
|
|
@@ -269,7 +291,7 @@ function startDefaultProtocol() {
|
|
|
269
291
|
handleResize();
|
|
270
292
|
});
|
|
271
293
|
if ("tapjoy" === AD_NETWORK && isTapjoy()) {
|
|
272
|
-
|
|
294
|
+
const tapjoyApi = {
|
|
273
295
|
skipAd: function() {
|
|
274
296
|
try {
|
|
275
297
|
sdk.finish();
|
|
@@ -378,6 +400,7 @@ var _sdk = class _sdk {
|
|
|
378
400
|
buildID: BUILD_HASH
|
|
379
401
|
});
|
|
380
402
|
}
|
|
403
|
+
fireVolumeChange(_sdk.volume);
|
|
381
404
|
_sdk.resize();
|
|
382
405
|
}
|
|
383
406
|
}
|
|
@@ -572,7 +595,7 @@ var _sdk = class _sdk {
|
|
|
572
595
|
}
|
|
573
596
|
};
|
|
574
597
|
/** Current version of the SDK */
|
|
575
|
-
_sdk.version = "1.0.
|
|
598
|
+
_sdk.version = "1.0.14";
|
|
576
599
|
/** Current maximum width of the playable ad container in pixels */
|
|
577
600
|
_sdk.maxWidth = Math.floor(window.innerWidth);
|
|
578
601
|
/** Current maximum height of the playable ad container in pixels */
|
|
@@ -588,7 +611,7 @@ _sdk.isPaused = false;
|
|
|
588
611
|
/** Indicates if the playable ad has finished */
|
|
589
612
|
_sdk.isFinished = false;
|
|
590
613
|
/** Current volume level (0-1) */
|
|
591
|
-
_sdk.volume =
|
|
614
|
+
_sdk.volume = actualVolume;
|
|
592
615
|
/** Number of user interactions with the playable ad */
|
|
593
616
|
_sdk.interactions = 0;
|
|
594
617
|
var sdk = _sdk;
|
package/dist/iife/index.js
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
function offEvent(event, fn, context) {
|
|
15
15
|
const listeners = registeredEvents[event];
|
|
16
16
|
if (!listeners) return;
|
|
17
|
-
|
|
17
|
+
const fnArray = listeners.list;
|
|
18
18
|
if (!fn) {
|
|
19
19
|
fnArray.length = 0;
|
|
20
20
|
} else {
|
|
@@ -31,12 +31,12 @@
|
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
function emitEvent(event, a1, a2, a3) {
|
|
34
|
-
|
|
34
|
+
const listeners = registeredEvents[event];
|
|
35
35
|
if (!listeners) return;
|
|
36
36
|
const fnArray = listeners.list;
|
|
37
37
|
const len = arguments.length;
|
|
38
38
|
let fn, ctx;
|
|
39
|
-
for (
|
|
39
|
+
for (let i = 0; i < fnArray.length; i += 3) {
|
|
40
40
|
fn = fnArray[i];
|
|
41
41
|
ctx = fnArray[i + 1];
|
|
42
42
|
if (fnArray[i + 2]) {
|
|
@@ -127,6 +127,7 @@
|
|
|
127
127
|
var isProtocolInitialized = false;
|
|
128
128
|
var isForcePaused = false;
|
|
129
129
|
var isInstallClicked = false;
|
|
130
|
+
var actualVolume = 1;
|
|
130
131
|
var initCallback = () => {
|
|
131
132
|
};
|
|
132
133
|
function bootAd() {
|
|
@@ -139,9 +140,17 @@
|
|
|
139
140
|
emitEvent("ready");
|
|
140
141
|
sdk.isReady = true;
|
|
141
142
|
}
|
|
142
|
-
function
|
|
143
|
+
function fireVolumeChange(value) {
|
|
143
144
|
emitEvent("volume", value);
|
|
144
145
|
}
|
|
146
|
+
function changeVolume(value) {
|
|
147
|
+
sdk.volume = value;
|
|
148
|
+
fireVolumeChange(value);
|
|
149
|
+
}
|
|
150
|
+
function handleVolumeChange(value) {
|
|
151
|
+
actualVolume = value;
|
|
152
|
+
if (!sdk.isPaused) changeVolume(actualVolume);
|
|
153
|
+
}
|
|
145
154
|
function handlePause() {
|
|
146
155
|
changeVolume(0);
|
|
147
156
|
sdk.isPaused = true;
|
|
@@ -149,7 +158,7 @@
|
|
|
149
158
|
}
|
|
150
159
|
function handleResume() {
|
|
151
160
|
if (isForcePaused) return;
|
|
152
|
-
changeVolume(
|
|
161
|
+
changeVolume(actualVolume);
|
|
153
162
|
sdk.isPaused = false;
|
|
154
163
|
emitEvent("resume");
|
|
155
164
|
}
|
|
@@ -176,7 +185,7 @@
|
|
|
176
185
|
if (sdk.isReady) {
|
|
177
186
|
handleResume();
|
|
178
187
|
} else {
|
|
179
|
-
|
|
188
|
+
const screenSize = dapi.getScreenSize();
|
|
180
189
|
screenSize.width = Math.floor(screenSize.width);
|
|
181
190
|
screenSize.height = Math.floor(screenSize.height);
|
|
182
191
|
bootAd();
|
|
@@ -193,18 +202,26 @@
|
|
|
193
202
|
if (!isProtocolInitialized) {
|
|
194
203
|
mraid.removeEventListener("ready", startMraidProtocol);
|
|
195
204
|
mraid.addEventListener("viewableChange", function() {
|
|
196
|
-
|
|
205
|
+
const isViewable = mraid.isViewable();
|
|
197
206
|
mraidIsViewable(isViewable);
|
|
198
207
|
});
|
|
199
208
|
if (mraid.isViewable() || AD_NETWORK == "adcolony") {
|
|
200
209
|
mraidIsViewable(true);
|
|
201
210
|
}
|
|
211
|
+
if (mraid.getAudioVolume) {
|
|
212
|
+
const isAudioEnabled = mraid.getAudioVolume();
|
|
213
|
+
if (isAudioEnabled) {
|
|
214
|
+
handleVolumeChange(1);
|
|
215
|
+
} else {
|
|
216
|
+
handleVolumeChange(0);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
202
219
|
mraid.addEventListener("audioVolumeChange", function(newVolume) {
|
|
203
220
|
if (newVolume !== null) {
|
|
204
221
|
if (newVolume > 0) {
|
|
205
|
-
|
|
222
|
+
handleVolumeChange(1);
|
|
206
223
|
} else {
|
|
207
|
-
|
|
224
|
+
handleVolumeChange(0);
|
|
208
225
|
}
|
|
209
226
|
}
|
|
210
227
|
});
|
|
@@ -212,7 +229,7 @@
|
|
|
212
229
|
console.log("mraid error: " + t + " action: " + e);
|
|
213
230
|
});
|
|
214
231
|
mraid.addEventListener("sizeChange", function() {
|
|
215
|
-
|
|
232
|
+
const maxSize = mraid.getMaxSize();
|
|
216
233
|
fireResizeEvent(maxSize.width, maxSize.height);
|
|
217
234
|
});
|
|
218
235
|
isProtocolInitialized = true;
|
|
@@ -222,17 +239,22 @@
|
|
|
222
239
|
if ("dapi" !== AD_PROTOCOL) return;
|
|
223
240
|
if (!isProtocolInitialized) {
|
|
224
241
|
dapi.removeEventListener("ready", startDapiProtocol);
|
|
225
|
-
dapi.getAudioVolume();
|
|
242
|
+
const isAudioEnabled = dapi.getAudioVolume();
|
|
243
|
+
if (isAudioEnabled) {
|
|
244
|
+
handleVolumeChange(1);
|
|
245
|
+
} else {
|
|
246
|
+
handleVolumeChange(0);
|
|
247
|
+
}
|
|
226
248
|
dapi.addEventListener("audioVolumeChange", function(volume) {
|
|
227
|
-
|
|
228
|
-
if (
|
|
229
|
-
|
|
249
|
+
const isAudioEnabled2 = !!volume;
|
|
250
|
+
if (isAudioEnabled2) {
|
|
251
|
+
handleVolumeChange(1);
|
|
230
252
|
} else {
|
|
231
|
-
|
|
253
|
+
handleVolumeChange(0);
|
|
232
254
|
}
|
|
233
255
|
});
|
|
234
256
|
dapi.addEventListener("adResized", function(event) {
|
|
235
|
-
|
|
257
|
+
const maxSize = dapi.getScreenSize();
|
|
236
258
|
fireResizeEvent(event.width || maxSize.width, event.height || maxSize.height);
|
|
237
259
|
});
|
|
238
260
|
if (dapi.isViewable()) {
|
|
@@ -271,7 +293,7 @@
|
|
|
271
293
|
handleResize();
|
|
272
294
|
});
|
|
273
295
|
if ("tapjoy" === AD_NETWORK && isTapjoy()) {
|
|
274
|
-
|
|
296
|
+
const tapjoyApi = {
|
|
275
297
|
skipAd: function() {
|
|
276
298
|
try {
|
|
277
299
|
sdk.finish();
|
|
@@ -380,6 +402,7 @@
|
|
|
380
402
|
buildID: BUILD_HASH
|
|
381
403
|
});
|
|
382
404
|
}
|
|
405
|
+
fireVolumeChange(_sdk.volume);
|
|
383
406
|
_sdk.resize();
|
|
384
407
|
}
|
|
385
408
|
}
|
|
@@ -574,7 +597,7 @@
|
|
|
574
597
|
}
|
|
575
598
|
};
|
|
576
599
|
/** Current version of the SDK */
|
|
577
|
-
_sdk.version = "1.0.
|
|
600
|
+
_sdk.version = "1.0.14";
|
|
578
601
|
/** Current maximum width of the playable ad container in pixels */
|
|
579
602
|
_sdk.maxWidth = Math.floor(window.innerWidth);
|
|
580
603
|
/** Current maximum height of the playable ad container in pixels */
|
|
@@ -590,7 +613,7 @@
|
|
|
590
613
|
/** Indicates if the playable ad has finished */
|
|
591
614
|
_sdk.isFinished = false;
|
|
592
615
|
/** Current volume level (0-1) */
|
|
593
|
-
_sdk.volume =
|
|
616
|
+
_sdk.volume = actualVolume;
|
|
594
617
|
/** Number of user interactions with the playable ad */
|
|
595
618
|
_sdk.interactions = 0;
|
|
596
619
|
var sdk = _sdk;
|
package/dist/index.js
CHANGED
|
@@ -39,7 +39,7 @@ function onEvent(event, fn, context, once) {
|
|
|
39
39
|
function offEvent(event, fn, context) {
|
|
40
40
|
const listeners = registeredEvents[event];
|
|
41
41
|
if (!listeners) return;
|
|
42
|
-
|
|
42
|
+
const fnArray = listeners.list;
|
|
43
43
|
if (!fn) {
|
|
44
44
|
fnArray.length = 0;
|
|
45
45
|
} else {
|
|
@@ -56,12 +56,12 @@ function offEvent(event, fn, context) {
|
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
58
|
function emitEvent(event, a1, a2, a3) {
|
|
59
|
-
|
|
59
|
+
const listeners = registeredEvents[event];
|
|
60
60
|
if (!listeners) return;
|
|
61
61
|
const fnArray = listeners.list;
|
|
62
62
|
const len = arguments.length;
|
|
63
63
|
let fn, ctx;
|
|
64
|
-
for (
|
|
64
|
+
for (let i = 0; i < fnArray.length; i += 3) {
|
|
65
65
|
fn = fnArray[i];
|
|
66
66
|
ctx = fnArray[i + 1];
|
|
67
67
|
if (fnArray[i + 2]) {
|
|
@@ -152,6 +152,7 @@ var isSDKInitialized = false;
|
|
|
152
152
|
var isProtocolInitialized = false;
|
|
153
153
|
var isForcePaused = false;
|
|
154
154
|
var isInstallClicked = false;
|
|
155
|
+
var actualVolume = 1;
|
|
155
156
|
var initCallback = () => {
|
|
156
157
|
};
|
|
157
158
|
function bootAd() {
|
|
@@ -164,9 +165,17 @@ function bootAd() {
|
|
|
164
165
|
emitEvent("ready");
|
|
165
166
|
sdk.isReady = true;
|
|
166
167
|
}
|
|
167
|
-
function
|
|
168
|
+
function fireVolumeChange(value) {
|
|
168
169
|
emitEvent("volume", value);
|
|
169
170
|
}
|
|
171
|
+
function changeVolume(value) {
|
|
172
|
+
sdk.volume = value;
|
|
173
|
+
fireVolumeChange(value);
|
|
174
|
+
}
|
|
175
|
+
function handleVolumeChange(value) {
|
|
176
|
+
actualVolume = value;
|
|
177
|
+
if (!sdk.isPaused) changeVolume(actualVolume);
|
|
178
|
+
}
|
|
170
179
|
function handlePause() {
|
|
171
180
|
changeVolume(0);
|
|
172
181
|
sdk.isPaused = true;
|
|
@@ -174,7 +183,7 @@ function handlePause() {
|
|
|
174
183
|
}
|
|
175
184
|
function handleResume() {
|
|
176
185
|
if (isForcePaused) return;
|
|
177
|
-
changeVolume(
|
|
186
|
+
changeVolume(actualVolume);
|
|
178
187
|
sdk.isPaused = false;
|
|
179
188
|
emitEvent("resume");
|
|
180
189
|
}
|
|
@@ -201,7 +210,7 @@ function dapiIsViewable(event) {
|
|
|
201
210
|
if (sdk.isReady) {
|
|
202
211
|
handleResume();
|
|
203
212
|
} else {
|
|
204
|
-
|
|
213
|
+
const screenSize = dapi.getScreenSize();
|
|
205
214
|
screenSize.width = Math.floor(screenSize.width);
|
|
206
215
|
screenSize.height = Math.floor(screenSize.height);
|
|
207
216
|
bootAd();
|
|
@@ -218,18 +227,26 @@ function startMraidProtocol() {
|
|
|
218
227
|
if (!isProtocolInitialized) {
|
|
219
228
|
mraid.removeEventListener("ready", startMraidProtocol);
|
|
220
229
|
mraid.addEventListener("viewableChange", function() {
|
|
221
|
-
|
|
230
|
+
const isViewable = mraid.isViewable();
|
|
222
231
|
mraidIsViewable(isViewable);
|
|
223
232
|
});
|
|
224
233
|
if (mraid.isViewable() || AD_NETWORK == "adcolony") {
|
|
225
234
|
mraidIsViewable(true);
|
|
226
235
|
}
|
|
236
|
+
if (mraid.getAudioVolume) {
|
|
237
|
+
const isAudioEnabled = mraid.getAudioVolume();
|
|
238
|
+
if (isAudioEnabled) {
|
|
239
|
+
handleVolumeChange(1);
|
|
240
|
+
} else {
|
|
241
|
+
handleVolumeChange(0);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
227
244
|
mraid.addEventListener("audioVolumeChange", function(newVolume) {
|
|
228
245
|
if (newVolume !== null) {
|
|
229
246
|
if (newVolume > 0) {
|
|
230
|
-
|
|
247
|
+
handleVolumeChange(1);
|
|
231
248
|
} else {
|
|
232
|
-
|
|
249
|
+
handleVolumeChange(0);
|
|
233
250
|
}
|
|
234
251
|
}
|
|
235
252
|
});
|
|
@@ -237,7 +254,7 @@ function startMraidProtocol() {
|
|
|
237
254
|
console.log("mraid error: " + t + " action: " + e);
|
|
238
255
|
});
|
|
239
256
|
mraid.addEventListener("sizeChange", function() {
|
|
240
|
-
|
|
257
|
+
const maxSize = mraid.getMaxSize();
|
|
241
258
|
fireResizeEvent(maxSize.width, maxSize.height);
|
|
242
259
|
});
|
|
243
260
|
isProtocolInitialized = true;
|
|
@@ -247,17 +264,22 @@ function startDapiProtocol() {
|
|
|
247
264
|
if ("dapi" !== AD_PROTOCOL) return;
|
|
248
265
|
if (!isProtocolInitialized) {
|
|
249
266
|
dapi.removeEventListener("ready", startDapiProtocol);
|
|
250
|
-
dapi.getAudioVolume();
|
|
267
|
+
const isAudioEnabled = dapi.getAudioVolume();
|
|
268
|
+
if (isAudioEnabled) {
|
|
269
|
+
handleVolumeChange(1);
|
|
270
|
+
} else {
|
|
271
|
+
handleVolumeChange(0);
|
|
272
|
+
}
|
|
251
273
|
dapi.addEventListener("audioVolumeChange", function(volume) {
|
|
252
|
-
|
|
253
|
-
if (
|
|
254
|
-
|
|
274
|
+
const isAudioEnabled2 = !!volume;
|
|
275
|
+
if (isAudioEnabled2) {
|
|
276
|
+
handleVolumeChange(1);
|
|
255
277
|
} else {
|
|
256
|
-
|
|
278
|
+
handleVolumeChange(0);
|
|
257
279
|
}
|
|
258
280
|
});
|
|
259
281
|
dapi.addEventListener("adResized", function(event) {
|
|
260
|
-
|
|
282
|
+
const maxSize = dapi.getScreenSize();
|
|
261
283
|
fireResizeEvent(event.width || maxSize.width, event.height || maxSize.height);
|
|
262
284
|
});
|
|
263
285
|
if (dapi.isViewable()) {
|
|
@@ -296,7 +318,7 @@ function startDefaultProtocol() {
|
|
|
296
318
|
handleResize();
|
|
297
319
|
});
|
|
298
320
|
if ("tapjoy" === AD_NETWORK && isTapjoy()) {
|
|
299
|
-
|
|
321
|
+
const tapjoyApi = {
|
|
300
322
|
skipAd: function() {
|
|
301
323
|
try {
|
|
302
324
|
sdk.finish();
|
|
@@ -405,6 +427,7 @@ var _sdk = class _sdk {
|
|
|
405
427
|
buildID: BUILD_HASH
|
|
406
428
|
});
|
|
407
429
|
}
|
|
430
|
+
fireVolumeChange(_sdk.volume);
|
|
408
431
|
_sdk.resize();
|
|
409
432
|
}
|
|
410
433
|
}
|
|
@@ -599,7 +622,7 @@ var _sdk = class _sdk {
|
|
|
599
622
|
}
|
|
600
623
|
};
|
|
601
624
|
/** Current version of the SDK */
|
|
602
|
-
_sdk.version = "1.0.
|
|
625
|
+
_sdk.version = "1.0.14";
|
|
603
626
|
/** Current maximum width of the playable ad container in pixels */
|
|
604
627
|
_sdk.maxWidth = Math.floor(window.innerWidth);
|
|
605
628
|
/** Current maximum height of the playable ad container in pixels */
|
|
@@ -615,7 +638,7 @@ _sdk.isPaused = false;
|
|
|
615
638
|
/** Indicates if the playable ad has finished */
|
|
616
639
|
_sdk.isFinished = false;
|
|
617
640
|
/** Current volume level (0-1) */
|
|
618
|
-
_sdk.volume =
|
|
641
|
+
_sdk.volume = actualVolume;
|
|
619
642
|
/** Number of user interactions with the playable ad */
|
|
620
643
|
_sdk.interactions = 0;
|
|
621
644
|
var sdk = _sdk;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@smoud/playable-sdk",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.14",
|
|
4
4
|
"description": "It's unified Playable SDK that supports MRAID, Google, Facebook, Vungle, and many more Ad Networks, simplifying playable ad development with a standardized interface for seamless cross-network compatibility.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|