@hopeplayer/core 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/dist/HopePlayerElement.d.ts +5 -0
- package/dist/HopePlayerElement.d.ts.map +1 -1
- package/dist/chunks/ScratchSound-0XKHUcJK.js +174 -0
- package/dist/chunks/ScratchSound-0XKHUcJK.js.map +1 -0
- package/dist/chunks/{index-Br_RybXV.js → index-BCMVXNL0.js} +71 -61
- package/dist/chunks/index-BCMVXNL0.js.map +1 -0
- package/dist/chunks/{index-DBwvWiuK.js → index-BTBAxNjr.js} +2 -2
- package/dist/chunks/{index-DBwvWiuK.js.map → index-BTBAxNjr.js.map} +1 -1
- package/dist/chunks/index-BeJNpAyx.js +326 -0
- package/dist/chunks/index-BeJNpAyx.js.map +1 -0
- package/dist/chunks/{index-nvfNBIM_.js → index-C2c71cGP.js} +2 -2
- package/dist/chunks/{index-nvfNBIM_.js.map → index-C2c71cGP.js.map} +1 -1
- package/dist/chunks/{index-adiWYyto.js → index-DcVUXkXo.js} +2 -2
- package/dist/chunks/{index-adiWYyto.js.map → index-DcVUXkXo.js.map} +1 -1
- package/dist/chunks/{index-C3s21eZa.js → index-DtqNHU7Y.js} +2 -2
- package/dist/chunks/{index-C3s21eZa.js.map → index-DtqNHU7Y.js.map} +1 -1
- package/dist/chunks/{index-_-pYIxvh.js → index-Dy0Th0is.js} +2 -2
- package/dist/chunks/{index-_-pYIxvh.js.map → index-Dy0Th0is.js.map} +1 -1
- package/dist/chunks/{index-D2aXO0eh.js → index-Dz0E1YPE.js} +610 -486
- package/dist/chunks/index-Dz0E1YPE.js.map +1 -0
- package/dist/controls/ControlBar.d.ts +17 -0
- package/dist/controls/ControlBar.d.ts.map +1 -1
- package/dist/controls/SeekBar.d.ts +8 -0
- package/dist/controls/SeekBar.d.ts.map +1 -1
- package/dist/controls/SettingsMenu.d.ts +4 -0
- package/dist/controls/SettingsMenu.d.ts.map +1 -1
- package/dist/hls/SourceManager.d.ts +2 -0
- package/dist/hls/SourceManager.d.ts.map +1 -1
- package/dist/hope-player.js +1 -1
- package/dist/i18n/locales/en.d.ts.map +1 -1
- package/dist/i18n/locales/tr.d.ts.map +1 -1
- package/dist/i18n/types.d.ts +2 -0
- package/dist/i18n/types.d.ts.map +1 -1
- package/dist/plugins/ads/AdsController.d.ts +2 -0
- package/dist/plugins/ads/AdsController.d.ts.map +1 -1
- package/dist/plugins/audio/AudioStage.d.ts +89 -0
- package/dist/plugins/audio/AudioStage.d.ts.map +1 -0
- package/dist/plugins/audio/ScratchSound.d.ts +48 -0
- package/dist/plugins/audio/ScratchSound.d.ts.map +1 -0
- package/dist/plugins/audio/index.d.ts +7 -0
- package/dist/plugins/audio/index.d.ts.map +1 -0
- package/dist/plugins/audio/vinylSvg.d.ts +12 -0
- package/dist/plugins/audio/vinylSvg.d.ts.map +1 -0
- package/dist/types/index.d.ts +63 -0
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/chunks/index-Br_RybXV.js.map +0 -1
- package/dist/chunks/index-D2aXO0eh.js.map +0 -1
|
@@ -56,6 +56,9 @@ export declare class HopePlayerElement extends HTMLElement {
|
|
|
56
56
|
private adsController;
|
|
57
57
|
private gestureControls;
|
|
58
58
|
private loopSection;
|
|
59
|
+
private audioStage;
|
|
60
|
+
/** options.audio — kapak + plak sahnesi, kontroller hep görünür, tam ekran yok. */
|
|
61
|
+
private audioMode;
|
|
59
62
|
private inViewAutoplay;
|
|
60
63
|
private unregisterSticky;
|
|
61
64
|
private playlistRunner;
|
|
@@ -244,6 +247,8 @@ export declare class HopePlayerElement extends HTMLElement {
|
|
|
244
247
|
/** Fare kıpırdadı: imleci göster, hareketsiz kalırsa gizlemek için sayacı yeniden kur (tailwind.css `:host([data-cursor-hidden])`). */
|
|
245
248
|
private scheduleCursorHide;
|
|
246
249
|
private showCursor;
|
|
250
|
+
/** options.audio: sahneyi kurar, günceller (konum / boyut / devir canlı değişebilir) ya da kaldırır. */
|
|
251
|
+
private applyAudioMode;
|
|
247
252
|
/** Ads plugin'ini bir kez kurar; erken (paralel) başlatılan kurulum varsa onu bekler. */
|
|
248
253
|
private installAdsOnce;
|
|
249
254
|
/** Preroll beklemesi başladı / bitti: halka döner, toolbar görünür kalır, oynat butonu "duraklat" görünür. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HopePlayerElement.d.ts","sourceRoot":"","sources":["../src/HopePlayerElement.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAc,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAC7D,OAAO,KAAK,GAAG,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAuC,KAAK,kBAAkB,EAA+C,MAAM,qBAAqB,CAAC;AAuBhJ,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"HopePlayerElement.d.ts","sourceRoot":"","sources":["../src/HopePlayerElement.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAc,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAC7D,OAAO,KAAK,GAAG,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAuC,KAAK,kBAAkB,EAA+C,MAAM,qBAAqB,CAAC;AAuBhJ,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AA2C5C,+DAA+D;AAC/D,eAAO,MAAM,mBAAmB,QAAmB,CAAC;AAoBpD,gHAAgH;AAChH,qBAAa,iBAAkB,SAAQ,WAAW;IAC9C,MAAM,KAAK,kBAAkB,IAAI,MAAM,EAAE,CAExC;IAED,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAa;IAClC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAiB;IAC3C,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAmB;IAC3C,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAiB;IAC3C,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAiB;IAC1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ACL"}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
var c = Object.defineProperty;
|
|
2
|
+
var u = (a, t, e) => t in a ? c(a, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : a[t] = e;
|
|
3
|
+
var n = (a, t, e) => u(a, typeof t != "symbol" ? t + "" : t, e);
|
|
4
|
+
const g = 900;
|
|
5
|
+
const d = `
|
|
6
|
+
class HopeScratchProcessor extends AudioWorkletProcessor {
|
|
7
|
+
constructor() {
|
|
8
|
+
super();
|
|
9
|
+
this.channels = null;
|
|
10
|
+
this.length = 0;
|
|
11
|
+
this.ratio = 1;
|
|
12
|
+
this.pos = 0;
|
|
13
|
+
this.target = 0;
|
|
14
|
+
this.rate = 0;
|
|
15
|
+
this.active = false;
|
|
16
|
+
this.blocks = 0;
|
|
17
|
+
this.port.onmessage = (e) => {
|
|
18
|
+
const d = e.data;
|
|
19
|
+
if (d.type === 'buffer') {
|
|
20
|
+
this.channels = d.channels;
|
|
21
|
+
this.length = d.channels[0].length;
|
|
22
|
+
this.ratio = d.sampleRate / sampleRate;
|
|
23
|
+
} else if (d.type === 'start') {
|
|
24
|
+
this.pos = this.target = d.position * (this.ratio * sampleRate);
|
|
25
|
+
this.rate = 0;
|
|
26
|
+
this.active = true;
|
|
27
|
+
} else if (d.type === 'target') {
|
|
28
|
+
this.target = Math.max(0, Math.min(this.length - 1, d.position * (this.ratio * sampleRate)));
|
|
29
|
+
} else if (d.type === 'stop') {
|
|
30
|
+
this.active = false;
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
process(inputs, outputs) {
|
|
35
|
+
const out = outputs[0];
|
|
36
|
+
const frames = out[0].length;
|
|
37
|
+
if (!this.active || !this.channels) {
|
|
38
|
+
for (const ch of out) ch.fill(0);
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
41
|
+
const src = this.channels;
|
|
42
|
+
const last = this.length - 1;
|
|
43
|
+
// Okuma kafası hedefe ~25 ms'lik bir gecikmeyle yaklaşır; hız değişimi ~5 ms'de yumuşatılır.
|
|
44
|
+
const lag = 0.025 * sampleRate;
|
|
45
|
+
const smooth = 1 / (0.005 * sampleRate);
|
|
46
|
+
const maxRate = 8 * this.ratio;
|
|
47
|
+
for (let i = 0; i < frames; i++) {
|
|
48
|
+
let want = (this.target - this.pos) / lag;
|
|
49
|
+
if (want > maxRate) want = maxRate;
|
|
50
|
+
else if (want < -maxRate) want = -maxRate;
|
|
51
|
+
this.rate += (want - this.rate) * smooth;
|
|
52
|
+
const p = this.pos;
|
|
53
|
+
const i0 = p | 0;
|
|
54
|
+
const f = p - i0;
|
|
55
|
+
const i1 = i0 < last ? i0 + 1 : last;
|
|
56
|
+
for (let c = 0; c < out.length; c++) {
|
|
57
|
+
const ch = src[c < src.length ? c : src.length - 1];
|
|
58
|
+
out[c][i] = ch[i0] + (ch[i1] - ch[i0]) * f;
|
|
59
|
+
}
|
|
60
|
+
let next = p + this.rate;
|
|
61
|
+
if (next < 0) next = 0;
|
|
62
|
+
else if (next > last) next = last;
|
|
63
|
+
this.pos = next;
|
|
64
|
+
}
|
|
65
|
+
if (++this.blocks % 8 === 0) this.port.postMessage({ type: 'position', position: this.pos / (this.ratio * sampleRate) });
|
|
66
|
+
return true;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
registerProcessor('hope-scratch', HopeScratchProcessor);
|
|
70
|
+
`;
|
|
71
|
+
class l {
|
|
72
|
+
constructor(t) {
|
|
73
|
+
n(this, "ctx", null);
|
|
74
|
+
n(this, "node", null);
|
|
75
|
+
n(this, "gain", null);
|
|
76
|
+
n(this, "loadedSrc", "");
|
|
77
|
+
n(this, "loading", null);
|
|
78
|
+
n(this, "unsupportedSrc", "");
|
|
79
|
+
n(this, "playing", !1);
|
|
80
|
+
/** İşlemcinin bildirdiği son okuma konumu (sn) — teşhis / test için. */
|
|
81
|
+
n(this, "lastPosition", 0);
|
|
82
|
+
n(this, "onStateChange", null);
|
|
83
|
+
this.video = t;
|
|
84
|
+
}
|
|
85
|
+
static isSupported() {
|
|
86
|
+
return typeof AudioContext < "u" && typeof AudioWorkletNode < "u" && "audioWorklet" in AudioContext.prototype;
|
|
87
|
+
}
|
|
88
|
+
/** Şu anki kaynak hazır mı (çözüldü + işlemci kuruldu)? */
|
|
89
|
+
get ready() {
|
|
90
|
+
return !!this.node && this.loadedSrc === this.currentSrc();
|
|
91
|
+
}
|
|
92
|
+
currentSrc() {
|
|
93
|
+
return this.video.currentSrc || "";
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Kaynağı çözer ve işlemciyi kurar (kaynak başına bir kez). Kullanıcı etkileşimi gerektirmez — çalma başlayınca
|
|
97
|
+
* boşta çağrılır ki ilk scratch'te gecikme olmasın.
|
|
98
|
+
*/
|
|
99
|
+
prepare() {
|
|
100
|
+
var e;
|
|
101
|
+
const t = this.currentSrc();
|
|
102
|
+
return this.ready ? Promise.resolve(!0) : !t || t === this.unsupportedSrc ? Promise.resolve(!1) : this.loading ? this.loading : (this.loading = this.load(t).then((s) => {
|
|
103
|
+
var o;
|
|
104
|
+
return s || (this.unsupportedSrc = t), (o = this.onStateChange) == null || o.call(this, s ? "ready" : "unsupported"), s;
|
|
105
|
+
}).finally(() => {
|
|
106
|
+
this.loading = null;
|
|
107
|
+
}), (e = this.onStateChange) == null || e.call(this, "loading"), this.loading);
|
|
108
|
+
}
|
|
109
|
+
async load(t) {
|
|
110
|
+
if (!l.isSupported() || t.startsWith("blob:") || /\.m3u8(\?|#|$)/i.test(t)) return !1;
|
|
111
|
+
const e = this.video.duration;
|
|
112
|
+
if (!Number.isFinite(e) || e <= 0 || e > 900) return !1;
|
|
113
|
+
try {
|
|
114
|
+
this.ctx ?? (this.ctx = new AudioContext({ latencyHint: "interactive" }));
|
|
115
|
+
const s = this.ctx;
|
|
116
|
+
if (!this.node) {
|
|
117
|
+
const i = URL.createObjectURL(new Blob([d], { type: "application/javascript" }));
|
|
118
|
+
try {
|
|
119
|
+
await s.audioWorklet.addModule(i);
|
|
120
|
+
} finally {
|
|
121
|
+
URL.revokeObjectURL(i);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
const o = await fetch(t, { credentials: "same-origin" });
|
|
125
|
+
if (!o.ok) return !1;
|
|
126
|
+
const r = await s.decodeAudioData(await o.arrayBuffer());
|
|
127
|
+
if (t !== this.currentSrc()) return !1;
|
|
128
|
+
this.node || (this.gain = s.createGain(), this.gain.gain.value = 0, this.gain.connect(s.destination), this.node = new AudioWorkletNode(s, "hope-scratch", { numberOfInputs: 0, outputChannelCount: [Math.min(2, r.numberOfChannels)] }), this.node.port.onmessage = (i) => {
|
|
129
|
+
i.data.type === "position" && (this.lastPosition = i.data.position);
|
|
130
|
+
}, this.node.connect(this.gain));
|
|
131
|
+
const h = [];
|
|
132
|
+
for (let i = 0; i < Math.min(2, r.numberOfChannels); i++) h.push(r.getChannelData(i).slice());
|
|
133
|
+
return this.node.port.postMessage({ type: "buffer", channels: h, sampleRate: r.sampleRate }, h.map((i) => i.buffer)), this.loadedSrc = t, !0;
|
|
134
|
+
} catch {
|
|
135
|
+
return !1;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
/** Plak tutuldu. Kullanıcı etkileşimi (pointerdown) içinde çağrılmalı — AudioContext'i başlatır. */
|
|
139
|
+
start(t) {
|
|
140
|
+
if (!this.ready || !this.ctx || !this.node || !this.gain) return;
|
|
141
|
+
this.ctx.resume().catch(() => {
|
|
142
|
+
});
|
|
143
|
+
const e = this.video.muted ? 0 : this.video.volume, s = this.ctx.currentTime;
|
|
144
|
+
this.gain.gain.cancelScheduledValues(s), this.gain.gain.setValueAtTime(0, s), this.gain.gain.linearRampToValueAtTime(e, s + 0.015), this.node.port.postMessage({ type: "start", position: t }), this.lastPosition = t, this.playing = !0;
|
|
145
|
+
}
|
|
146
|
+
/** Parmağın gösterdiği konum (sn). */
|
|
147
|
+
setTarget(t) {
|
|
148
|
+
!this.playing || !this.node || this.node.port.postMessage({ type: "target", position: t });
|
|
149
|
+
}
|
|
150
|
+
/** Plak bırakıldı: kısa bir sönümle sus (çıtırtı olmasın). */
|
|
151
|
+
stop() {
|
|
152
|
+
if (!this.playing || !this.ctx || !this.node || !this.gain) return;
|
|
153
|
+
this.playing = !1;
|
|
154
|
+
const t = this.ctx.currentTime;
|
|
155
|
+
this.gain.gain.cancelScheduledValues(t), this.gain.gain.setValueAtTime(this.gain.gain.value, t), this.gain.gain.linearRampToValueAtTime(0, t + 0.015);
|
|
156
|
+
const e = this.node;
|
|
157
|
+
setTimeout(() => {
|
|
158
|
+
this.playing || e.port.postMessage({ type: "stop" });
|
|
159
|
+
}, 0.015 * 1e3 + 10);
|
|
160
|
+
}
|
|
161
|
+
get active() {
|
|
162
|
+
return this.playing;
|
|
163
|
+
}
|
|
164
|
+
destroy() {
|
|
165
|
+
var t, e, s;
|
|
166
|
+
this.playing = !1, (t = this.node) == null || t.disconnect(), (e = this.gain) == null || e.disconnect(), this.node = null, this.gain = null, (s = this.ctx) == null || s.close().catch(() => {
|
|
167
|
+
}), this.ctx = null;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
export {
|
|
171
|
+
g as SCRATCH_SOUND_MAX_SECONDS,
|
|
172
|
+
l as ScratchSound
|
|
173
|
+
};
|
|
174
|
+
//# sourceMappingURL=ScratchSound-0XKHUcJK.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ScratchSound-0XKHUcJK.js","sources":["../../src/plugins/audio/ScratchSound.ts"],"sourcesContent":["/**\n * Plak scratch sesi (options.audio.vinyl.scratchSound). `<audio>/<video>` geriye çalamaz ve sarma sırasında ses vermez;\n * bu yüzden scratch boyunca ses Web Audio ile üretilir: dosya bir kez ham sese çözülür, bir AudioWorklet bu sesi\n * parmağın gösterdiği konuma doğru (ileri / geri, yavaş / hızlı) okur — parmak durunca okuma da durur, ses kesilir.\n *\n * Konum güdümlü: işlemciye hız değil hedef konum verilir; okuma kafası hedefe kısa bir gecikmeyle (yay gibi) yaklaşır.\n * Böylece ses ile plağın açısı hiçbir zaman birbirinden kaymaz ve hız değişimleri yumuşak duyulur.\n *\n * Desteklenmeyen durumlarda (HLS / MediaSource, çok uzun dosya, CORS izni yok, AudioWorklet yok) `prepare()` false\n * döner ve scratch eskisi gibi sessiz çalışır.\n */\n\n/** Bundan uzun dosyalar çözülmez — çözülmüş ses dakikada ~10 MB yer kaplar. */\nexport const SCRATCH_SOUND_MAX_SECONDS = 15 * 60;\nconst FADE_SECONDS = 0.015;\n\nconst WORKLET_SOURCE = `\nclass HopeScratchProcessor extends AudioWorkletProcessor {\n constructor() {\n super();\n this.channels = null;\n this.length = 0;\n this.ratio = 1;\n this.pos = 0;\n this.target = 0;\n this.rate = 0;\n this.active = false;\n this.blocks = 0;\n this.port.onmessage = (e) => {\n const d = e.data;\n if (d.type === 'buffer') {\n this.channels = d.channels;\n this.length = d.channels[0].length;\n this.ratio = d.sampleRate / sampleRate;\n } else if (d.type === 'start') {\n this.pos = this.target = d.position * (this.ratio * sampleRate);\n this.rate = 0;\n this.active = true;\n } else if (d.type === 'target') {\n this.target = Math.max(0, Math.min(this.length - 1, d.position * (this.ratio * sampleRate)));\n } else if (d.type === 'stop') {\n this.active = false;\n }\n };\n }\n process(inputs, outputs) {\n const out = outputs[0];\n const frames = out[0].length;\n if (!this.active || !this.channels) {\n for (const ch of out) ch.fill(0);\n return true;\n }\n const src = this.channels;\n const last = this.length - 1;\n // Okuma kafası hedefe ~25 ms'lik bir gecikmeyle yaklaşır; hız değişimi ~5 ms'de yumuşatılır.\n const lag = 0.025 * sampleRate;\n const smooth = 1 / (0.005 * sampleRate);\n const maxRate = 8 * this.ratio;\n for (let i = 0; i < frames; i++) {\n let want = (this.target - this.pos) / lag;\n if (want > maxRate) want = maxRate;\n else if (want < -maxRate) want = -maxRate;\n this.rate += (want - this.rate) * smooth;\n const p = this.pos;\n const i0 = p | 0;\n const f = p - i0;\n const i1 = i0 < last ? i0 + 1 : last;\n for (let c = 0; c < out.length; c++) {\n const ch = src[c < src.length ? c : src.length - 1];\n out[c][i] = ch[i0] + (ch[i1] - ch[i0]) * f;\n }\n let next = p + this.rate;\n if (next < 0) next = 0;\n else if (next > last) next = last;\n this.pos = next;\n }\n if (++this.blocks % 8 === 0) this.port.postMessage({ type: 'position', position: this.pos / (this.ratio * sampleRate) });\n return true;\n }\n}\nregisterProcessor('hope-scratch', HopeScratchProcessor);\n`;\n\ntype State = 'idle' | 'loading' | 'ready' | 'unsupported';\n\nexport class ScratchSound {\n private ctx: AudioContext | null = null;\n private node: AudioWorkletNode | null = null;\n private gain: GainNode | null = null;\n private loadedSrc = '';\n private loading: Promise<boolean> | null = null;\n private unsupportedSrc = '';\n private playing = false;\n /** İşlemcinin bildirdiği son okuma konumu (sn) — teşhis / test için. */\n lastPosition = 0;\n onStateChange: ((state: State) => void) | null = null;\n\n constructor(private readonly video: HTMLMediaElement) {}\n\n static isSupported(): boolean {\n return typeof AudioContext !== 'undefined' && typeof AudioWorkletNode !== 'undefined' && 'audioWorklet' in AudioContext.prototype;\n }\n\n /** Şu anki kaynak hazır mı (çözüldü + işlemci kuruldu)? */\n get ready(): boolean {\n return !!this.node && this.loadedSrc === this.currentSrc();\n }\n\n private currentSrc(): string {\n return this.video.currentSrc || '';\n }\n\n /**\n * Kaynağı çözer ve işlemciyi kurar (kaynak başına bir kez). Kullanıcı etkileşimi gerektirmez — çalma başlayınca\n * boşta çağrılır ki ilk scratch'te gecikme olmasın.\n */\n prepare(): Promise<boolean> {\n const src = this.currentSrc();\n if (this.ready) return Promise.resolve(true);\n if (!src || src === this.unsupportedSrc) return Promise.resolve(false);\n if (this.loading) return this.loading;\n this.loading = this.load(src)\n .then((ok) => {\n if (!ok) this.unsupportedSrc = src;\n this.onStateChange?.(ok ? 'ready' : 'unsupported');\n return ok;\n })\n .finally(() => {\n this.loading = null;\n });\n this.onStateChange?.('loading');\n return this.loading;\n }\n\n private async load(src: string): Promise<boolean> {\n // HLS (MediaSource / blob:) parça parça gelir — tek dosya olarak çözülemez.\n if (!ScratchSound.isSupported() || src.startsWith('blob:') || /\\.m3u8(\\?|#|$)/i.test(src)) return false;\n const duration = this.video.duration;\n if (!Number.isFinite(duration) || duration <= 0 || duration > SCRATCH_SOUND_MAX_SECONDS) return false;\n try {\n this.ctx ??= new AudioContext({ latencyHint: 'interactive' });\n const ctx = this.ctx;\n if (!this.node) {\n const url = URL.createObjectURL(new Blob([WORKLET_SOURCE], { type: 'application/javascript' }));\n try {\n await ctx.audioWorklet.addModule(url);\n } finally {\n URL.revokeObjectURL(url);\n }\n }\n // Başka sunucudaki dosya için o sunucunun CORS izni gerekir; yoksa fetch reddedilir.\n const res = await fetch(src, { credentials: 'same-origin' });\n if (!res.ok) return false;\n const buffer = await ctx.decodeAudioData(await res.arrayBuffer());\n if (src !== this.currentSrc()) return false; // çözülürken kaynak değişti\n if (!this.node) {\n this.gain = ctx.createGain();\n this.gain.gain.value = 0;\n this.gain.connect(ctx.destination);\n this.node = new AudioWorkletNode(ctx, 'hope-scratch', { numberOfInputs: 0, outputChannelCount: [Math.min(2, buffer.numberOfChannels)] });\n this.node.port.onmessage = (e: MessageEvent<{ type: string; position: number }>) => {\n if (e.data.type === 'position') this.lastPosition = e.data.position;\n };\n this.node.connect(this.gain);\n }\n const channels: Float32Array[] = [];\n for (let c = 0; c < Math.min(2, buffer.numberOfChannels); c++) channels.push(buffer.getChannelData(c).slice());\n this.node.port.postMessage({ type: 'buffer', channels, sampleRate: buffer.sampleRate }, channels.map((ch) => ch.buffer));\n this.loadedSrc = src;\n return true;\n } catch {\n return false;\n }\n }\n\n /** Plak tutuldu. Kullanıcı etkileşimi (pointerdown) içinde çağrılmalı — AudioContext'i başlatır. */\n start(position: number): void {\n if (!this.ready || !this.ctx || !this.node || !this.gain) return;\n void this.ctx.resume().catch(() => {});\n const volume = this.video.muted ? 0 : this.video.volume;\n const now = this.ctx.currentTime;\n this.gain.gain.cancelScheduledValues(now);\n this.gain.gain.setValueAtTime(0, now);\n this.gain.gain.linearRampToValueAtTime(volume, now + FADE_SECONDS);\n this.node.port.postMessage({ type: 'start', position });\n this.lastPosition = position;\n this.playing = true;\n }\n\n /** Parmağın gösterdiği konum (sn). */\n setTarget(position: number): void {\n if (!this.playing || !this.node) return;\n this.node.port.postMessage({ type: 'target', position });\n }\n\n /** Plak bırakıldı: kısa bir sönümle sus (çıtırtı olmasın). */\n stop(): void {\n if (!this.playing || !this.ctx || !this.node || !this.gain) return;\n this.playing = false;\n const now = this.ctx.currentTime;\n this.gain.gain.cancelScheduledValues(now);\n this.gain.gain.setValueAtTime(this.gain.gain.value, now);\n this.gain.gain.linearRampToValueAtTime(0, now + FADE_SECONDS);\n const node = this.node;\n // Sönüm bitince işlemciyi durdur — o arada plak yeniden tutulduysa (hızlı tut-bırak-tut) yeni scratch'i kesme.\n setTimeout(() => {\n if (!this.playing) node.port.postMessage({ type: 'stop' });\n }, FADE_SECONDS * 1000 + 10);\n }\n\n get active(): boolean {\n return this.playing;\n }\n\n destroy(): void {\n this.playing = false;\n this.node?.disconnect();\n this.gain?.disconnect();\n this.node = null;\n this.gain = null;\n void this.ctx?.close().catch(() => {});\n this.ctx = null;\n }\n}\n"],"names":["SCRATCH_SOUND_MAX_SECONDS","WORKLET_SOURCE","ScratchSound","video","__publicField","_a","src","ok","duration","ctx","url","res","buffer","e","channels","c","ch","position","volume","now","node","_b","_c"],"mappings":";;;AAaO,MAAMA,IAA4B;AAGzC,MAAMC,IAAiB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;A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AAK,KAAK,KAAK,wBAAwB,GAAGA,IAAM,KAAY;AAC5D,UAAMC,IAAO,KAAK;AAElB,eAAW,MAAM;AACb,MAAK,KAAK,WAASA,EAAK,KAAK,YAAY,EAAE,MAAM,QAAQ;AAAA,IAC7D,GAAG,QAAe,MAAO,EAAE;AAAA,EAC/B;AAAA,EAEA,IAAI,SAAkB;AAClB,WAAO,KAAK;AAAA,EAChB;AAAA,EAEA,UAAgB;AAzMb,QAAAf,GAAAgB,GAAAC;AA0MC,SAAK,UAAU,KACfjB,IAAA,KAAK,SAAL,QAAAA,EAAW,eACXgB,IAAA,KAAK,SAAL,QAAAA,EAAW,cACX,KAAK,OAAO,MACZ,KAAK,OAAO,OACPC,IAAA,KAAK,QAAL,QAAAA,EAAU,QAAQ,MAAM,MAAM;AAAA,IAAC,IACpC,KAAK,MAAM;AAAA,EACf;AACJ;"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
var T = Object.defineProperty;
|
|
2
|
-
var P = (
|
|
3
|
-
var r = (
|
|
2
|
+
var P = (d, e, t) => e in d ? T(d, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : d[e] = t;
|
|
3
|
+
var r = (d, e, t) => P(d, typeof e != "symbol" ? e + "" : e, t);
|
|
4
4
|
class k {
|
|
5
5
|
constructor(e) {
|
|
6
6
|
/** Reklam yüzünden çıkılan yüzey — reklam bitince geri dönüş butonu için. */
|
|
@@ -60,8 +60,8 @@ class k {
|
|
|
60
60
|
const M = "https://imasdk.googleapis.com/js/sdkloader/ima3.js";
|
|
61
61
|
let g = null;
|
|
62
62
|
function L() {
|
|
63
|
-
var
|
|
64
|
-
return (
|
|
63
|
+
var d;
|
|
64
|
+
return (d = window.google) != null && d.ima ? Promise.resolve(window.google.ima) : g || (g = new Promise((e, t) => {
|
|
65
65
|
const i = document.createElement("script");
|
|
66
66
|
i.src = M, i.async = !0, i.onload = () => {
|
|
67
67
|
var s;
|
|
@@ -69,7 +69,7 @@ function L() {
|
|
|
69
69
|
}, i.onerror = () => t(new Error("IMA SDK yüklenemedi (reklam engelleyici olabilir)")), document.head.appendChild(i);
|
|
70
70
|
}), g);
|
|
71
71
|
}
|
|
72
|
-
function
|
|
72
|
+
function x() {
|
|
73
73
|
var i;
|
|
74
74
|
const e = (i = window.adTaxonomy) == null ? void 0 : i.keyValues;
|
|
75
75
|
if (!e || typeof e != "object") return "";
|
|
@@ -78,9 +78,9 @@ function C() {
|
|
|
78
78
|
a == null || a === "" || t.push(`${s}=${a}`);
|
|
79
79
|
return t.join("&");
|
|
80
80
|
}
|
|
81
|
-
function
|
|
81
|
+
function C(d, e = {}) {
|
|
82
82
|
const t = encodeURIComponent(document.referrer || window.location.href), i = encodeURIComponent(window.location.href), s = Date.now();
|
|
83
|
-
let a =
|
|
83
|
+
let a = d;
|
|
84
84
|
const o = {
|
|
85
85
|
referrer_url: t,
|
|
86
86
|
description_url: i,
|
|
@@ -91,17 +91,17 @@ function x(l, e = {}) {
|
|
|
91
91
|
if (a.includes(h))
|
|
92
92
|
a = a.replace(h, String(c));
|
|
93
93
|
else if (!new URLSearchParams(a.split("?")[1]).has(n)) {
|
|
94
|
-
const
|
|
95
|
-
a += `${
|
|
94
|
+
const l = a.includes("?") ? "&" : "?";
|
|
95
|
+
a += `${l}${n}=${c}`;
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
98
|
try {
|
|
99
99
|
const n = new URL(a);
|
|
100
|
-
if (n.pathname.includes("/vmap/")) return
|
|
100
|
+
if (n.pathname.includes("/vmap/")) return d;
|
|
101
101
|
const h = [];
|
|
102
102
|
e.includeRefreshCount && h.push(`adrefreshCount=${e.adRefreshCount ?? 0}`);
|
|
103
|
-
const
|
|
104
|
-
if (
|
|
103
|
+
const l = x();
|
|
104
|
+
if (l && h.push(l), h.length) {
|
|
105
105
|
const u = n.searchParams.get("cust_params");
|
|
106
106
|
n.searchParams.set("cust_params", u ? `${u}&${h.join("&")}` : h.join("&"));
|
|
107
107
|
}
|
|
@@ -146,9 +146,9 @@ class b {
|
|
|
146
146
|
n.attemptsOnCurrent++;
|
|
147
147
|
const c = this.config.maxAttemptsPerTag ?? 1 / 0;
|
|
148
148
|
n.attemptsOnCurrent > c && n.index < n.tags.length - 1 && (n.index++, n.attemptsOnCurrent = 1);
|
|
149
|
-
const h = n.tags[n.index],
|
|
149
|
+
const h = n.tags[n.index], l = this.adRetryCount;
|
|
150
150
|
this.retryTimer = setTimeout(() => {
|
|
151
|
-
this.retryTimer = null, i(h,
|
|
151
|
+
this.retryTimer = null, i(h, l);
|
|
152
152
|
}, this.applyJitter(this.resolveRetryDelay()));
|
|
153
153
|
}
|
|
154
154
|
getChainState(e, t) {
|
|
@@ -180,16 +180,16 @@ class b {
|
|
|
180
180
|
return Math.max(0, Math.round(e * i));
|
|
181
181
|
}
|
|
182
182
|
}
|
|
183
|
-
function E(
|
|
183
|
+
function E(d, e) {
|
|
184
184
|
var t;
|
|
185
185
|
try {
|
|
186
|
-
(t =
|
|
186
|
+
(t = d == null ? void 0 : d.settings) != null && t.setPrivacySettings && (d.settings.setPrivacySettings({ nonPersonalizedAds: !0 }), console.warn(`[HopePlayer consent] non-personalized ads zorlandı (${e})`));
|
|
187
187
|
} catch (i) {
|
|
188
188
|
console.warn("[HopePlayer consent] setPrivacySettings hatası:", i);
|
|
189
189
|
}
|
|
190
190
|
}
|
|
191
|
-
function S(
|
|
192
|
-
if (
|
|
191
|
+
function S(d, e) {
|
|
192
|
+
if (d.consentAware) {
|
|
193
193
|
try {
|
|
194
194
|
typeof window.__uspapi == "function" && window.__uspapi("getUSPData", 1, (t, i) => {
|
|
195
195
|
!i || !(t != null && t.uspString) || t.uspString.charAt(2) === "Y" && E(e, "USP/CCPA opt-out");
|
|
@@ -209,20 +209,20 @@ function S(l, e) {
|
|
|
209
209
|
}
|
|
210
210
|
}
|
|
211
211
|
}
|
|
212
|
-
function R(
|
|
212
|
+
function R(d) {
|
|
213
213
|
try {
|
|
214
|
-
const e = atob(
|
|
215
|
-
for (let
|
|
214
|
+
const e = atob(d), t = new Uint8Array(e.length);
|
|
215
|
+
for (let l = 0; l < e.length; l++) t[l] = e.charCodeAt(l);
|
|
216
216
|
if (t[0] !== 252 || t[13] !== 5) return null;
|
|
217
217
|
const s = (t[14] << 24 | t[15] << 16 | t[16] << 8 | t[17]) >>> 0;
|
|
218
218
|
if (t[18] >> 7 & 1) return { type: "cancel", spliceEventId: s };
|
|
219
219
|
const o = t[19] >> 7 & 1, n = t[19] >> 6 & 1, c = t[19] >> 5 & 1;
|
|
220
220
|
let h = null;
|
|
221
221
|
if (n) {
|
|
222
|
-
let
|
|
223
|
-
const u = t[
|
|
224
|
-
if (
|
|
225
|
-
const p = t[
|
|
222
|
+
let l = 20;
|
|
223
|
+
const u = t[l] >> 7 & 1;
|
|
224
|
+
if (l += u ? 5 : 1, c) {
|
|
225
|
+
const p = t[l] >> 7 & 1, f = (t[l] & 1) * Math.pow(2, 32) + t[l + 1] * Math.pow(2, 24) + t[l + 2] * Math.pow(2, 16) + t[l + 3] * Math.pow(2, 8) + t[l + 4];
|
|
226
226
|
h = { autoReturn: p, seconds: f / 9e4 };
|
|
227
227
|
}
|
|
228
228
|
}
|
|
@@ -231,18 +231,18 @@ function R(l) {
|
|
|
231
231
|
return null;
|
|
232
232
|
}
|
|
233
233
|
}
|
|
234
|
-
function w(
|
|
235
|
-
if (
|
|
234
|
+
function w(d, e) {
|
|
235
|
+
if (d === "EXT-X-CUE-OUT")
|
|
236
236
|
return { type: "out", duration: parseFloat(e) || null };
|
|
237
|
-
if (
|
|
237
|
+
if (d === "EXT-X-CUE-IN")
|
|
238
238
|
return { type: "in" };
|
|
239
|
-
if (
|
|
239
|
+
if (d === "EXT-X-DATERANGE") {
|
|
240
240
|
const t = e.match(/SCTE35-OUT=0x([0-9A-Fa-f]+)/), i = e.match(/SCTE35-IN=0x([0-9A-Fa-f]+)/), s = e.match(/PLANNED-DURATION=([\d.]+)/), a = e.match(/CLASS="([^"]+)"/);
|
|
241
241
|
if (t)
|
|
242
242
|
return { type: "out", duration: s ? parseFloat(s[1]) : null, class: a ? a[1] : null, raw: t[1] };
|
|
243
243
|
if (i) return { type: "in", raw: i[1] };
|
|
244
244
|
}
|
|
245
|
-
return
|
|
245
|
+
return d === "EXT-OATCLS-SCTE35" ? R(e) : null;
|
|
246
246
|
}
|
|
247
247
|
class B {
|
|
248
248
|
constructor(e, t) {
|
|
@@ -310,8 +310,8 @@ class B {
|
|
|
310
310
|
}
|
|
311
311
|
}
|
|
312
312
|
const I = 250, O = 300 * 1e3, q = "100% 0px 100% 0px";
|
|
313
|
-
function V(
|
|
314
|
-
return e === "Preroll" ?
|
|
313
|
+
function V(d, e) {
|
|
314
|
+
return e === "Preroll" ? d.adTagPreroll : e === "Midroll" ? d.adTagMidroll : d.adTagPostroll;
|
|
315
315
|
}
|
|
316
316
|
class U {
|
|
317
317
|
constructor(e, t) {
|
|
@@ -515,17 +515,22 @@ class U {
|
|
|
515
515
|
});
|
|
516
516
|
/** Lineer reklam başladı: pod bilgisi + kalan süre toolbar'a (geri sayım). */
|
|
517
517
|
r(this, "onAdStarted", (e) => {
|
|
518
|
-
var
|
|
519
|
-
const t = (
|
|
520
|
-
if (!
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
}
|
|
527
|
-
this.stopAdProgress(), this.reportAdProgress(), this.progressTimer = setInterval(this.reportAdProgress, I);
|
|
518
|
+
var s, a;
|
|
519
|
+
const t = (s = e == null ? void 0 : e.getAd) == null ? void 0 : s.call(e);
|
|
520
|
+
if (!t || typeof t.isLinear == "function" && !t.isLinear()) return;
|
|
521
|
+
try {
|
|
522
|
+
const o = t.getAdPodInfo();
|
|
523
|
+
this.podPosition = o.getAdPosition() || 1, this.podTotal = o.getTotalAds() || 1;
|
|
524
|
+
} catch {
|
|
525
|
+
this.podPosition = 1, this.podTotal = 1;
|
|
528
526
|
}
|
|
527
|
+
this.stopAdProgress(), this.reportAdProgress(), this.progressTimer = setInterval(this.reportAdProgress, I);
|
|
528
|
+
let i = "";
|
|
529
|
+
try {
|
|
530
|
+
i = ((a = t.getContentType) == null ? void 0 : a.call(t)) ?? "";
|
|
531
|
+
} catch {
|
|
532
|
+
}
|
|
533
|
+
this.ctx.adLayerEl.toggleAttribute("data-audio-ad", i.startsWith("audio/"));
|
|
529
534
|
});
|
|
530
535
|
r(this, "reportAdProgress", () => {
|
|
531
536
|
var t, i, s;
|
|
@@ -539,14 +544,14 @@ class U {
|
|
|
539
544
|
this.ctx = e, this.options = t, this.retry = new b(t.retry ?? {}), this.prebidIdSuffix = e.hostEl.id || Math.random().toString(36).slice(2, 8), this.surfaceGuard = e.surface ? new k(e.surface) : null;
|
|
540
545
|
}
|
|
541
546
|
async install() {
|
|
542
|
-
var s, a, o, n;
|
|
547
|
+
var s, a, o, n, c, h;
|
|
543
548
|
let e;
|
|
544
549
|
const t = this.ctx.prerollGate;
|
|
545
550
|
t && (t.onPlayIntent = this.onPrerollPlayIntent, t.onTimeout = this.onPrerollTimeout);
|
|
546
551
|
try {
|
|
547
552
|
e = await L();
|
|
548
|
-
} catch (
|
|
549
|
-
t == null || t.release(!0), (a = (s = this.ctx).log) == null || a.call(s, { message: `IMA SDK failed to load: ${String(
|
|
553
|
+
} catch (l) {
|
|
554
|
+
t == null || t.release(!0), (a = (s = this.ctx).log) == null || a.call(s, { message: `IMA SDK failed to load: ${String(l)}`, details: { hint: "ad blocker / network" } }), this.ctx.hostEl.dispatchEvent(new CustomEvent("hp:aderror", { detail: { message: String(l), errorType: "sdkLoadError" } }));
|
|
550
555
|
return;
|
|
551
556
|
}
|
|
552
557
|
this.ima = e;
|
|
@@ -566,10 +571,15 @@ class U {
|
|
|
566
571
|
(o = e.ImaSdkSettings) != null && o.VpaidMode && e.settings.setVpaidMode(e.ImaSdkSettings.VpaidMode.INSECURE);
|
|
567
572
|
} catch {
|
|
568
573
|
}
|
|
569
|
-
S(this.options, this.ima), this.
|
|
574
|
+
if (S(this.options, this.ima), this.ctx.audioPoster)
|
|
575
|
+
try {
|
|
576
|
+
(c = (n = e.settings).setFeatureFlags) == null || c.call(n, { audioPosterImageEnabled: !0, audioPosterImageDefaultUrl: this.ctx.audioPoster });
|
|
577
|
+
} catch {
|
|
578
|
+
}
|
|
579
|
+
this.adDisplayContainer = new e.AdDisplayContainer(this.ctx.adLayerEl, this.ctx.videoEl), typeof ResizeObserver < "u" && (this.resizeObserver = new ResizeObserver(this.scheduleResize), this.resizeObserver.observe(this.ctx.videoEl)), this.adsLoader = new e.AdsLoader(this.adDisplayContainer), this.adsLoader.addEventListener(e.AdsManagerLoadedEvent.Type.ADS_MANAGER_LOADED, this.onAdsManagerLoaded), this.adsLoader.addEventListener(e.AdErrorEvent.Type.AD_ERROR, this.onAdsLoaderError), this.ctx.videoEl.addEventListener("play", this.initializeDisplayContainerOnce);
|
|
570
580
|
const i = typeof navigator < "u" && "userActivation" in navigator && navigator.userActivation.hasBeenActive;
|
|
571
|
-
(!this.ctx.videoEl.paused || i || t != null && t.hasPlayIntent) && this.initializeDisplayContainerOnce(), this.ctx.videoEl.addEventListener("ended", this.onContentEnded), this.options.adTagMidroll && !this.options.adTagVmap && this.options.midrollIntervalSeconds && this.ctx.videoEl.addEventListener("timeupdate", this.onTimeUpdateForMidroll), this.requestInitialPrerollOrVmap(), (
|
|
572
|
-
onAdBreakStart: (
|
|
581
|
+
(!this.ctx.videoEl.paused || i || t != null && t.hasPlayIntent) && this.initializeDisplayContainerOnce(), this.ctx.videoEl.addEventListener("ended", this.onContentEnded), this.options.adTagMidroll && !this.options.adTagVmap && this.options.midrollIntervalSeconds && this.ctx.videoEl.addEventListener("timeupdate", this.onTimeUpdateForMidroll), this.requestInitialPrerollOrVmap(), (h = this.options.live) != null && h.scte35 && this.options.live.adTagLive && (this.scte35Manager = new B(this.ctx.videoEl, {
|
|
582
|
+
onAdBreakStart: (l) => this.onScte35AdBreakStart(l),
|
|
573
583
|
onAdBreakEnd: () => this.onScte35AdBreakEnd()
|
|
574
584
|
}));
|
|
575
585
|
}
|
|
@@ -651,11 +661,11 @@ class U {
|
|
|
651
661
|
return this.prebidInstances[e] = o, o;
|
|
652
662
|
}
|
|
653
663
|
async requestAd(e, t, i = 0, s = !1) {
|
|
654
|
-
var h,
|
|
664
|
+
var h, l, u, p, y, f, A;
|
|
655
665
|
if (!this.adsLoader || !this.ima) return;
|
|
656
666
|
this.currentBreakType = e, this.lastRequestIsVmap = s;
|
|
657
667
|
const a = Array.isArray(t) ? t[0] : t;
|
|
658
|
-
let o = s ? a :
|
|
668
|
+
let o = s ? a : C(a, { includeRefreshCount: !!((h = this.options.retry) != null && h.enabled), adRefreshCount: i });
|
|
659
669
|
if (!s && i === 0) {
|
|
660
670
|
const m = this.getPrebidConfigFor(e);
|
|
661
671
|
if (m) {
|
|
@@ -667,7 +677,7 @@ class U {
|
|
|
667
677
|
const n = new this.ima.AdsRequest();
|
|
668
678
|
n.adTagUrl = o, n.linearAdSlotWidth = this.ctx.videoEl.clientWidth || 640, n.linearAdSlotHeight = this.ctx.videoEl.clientHeight || 360, n.nonLinearAdSlotWidth = this.ctx.videoEl.clientWidth || 640, n.nonLinearAdSlotHeight = Math.round((this.ctx.videoEl.clientHeight || 360) / 3), n.vastLoadTimeout = this.options.vastLoadTimeoutMs ?? 1e4;
|
|
669
679
|
try {
|
|
670
|
-
(u = n.setAdWillAutoPlay) == null || u.call(n, this.ctx.videoEl.autoplay || !!((
|
|
680
|
+
(u = n.setAdWillAutoPlay) == null || u.call(n, this.ctx.videoEl.autoplay || !!((l = this.ctx.prerollGate) != null && l.hasPlayIntent) || !this.ctx.videoEl.paused), (p = n.setAdWillPlayMuted) == null || p.call(n, this.ctx.videoEl.muted), (A = n.setContinuousPlayback) == null || A.call(n, !!((f = (y = this.ctx).isContinuousPlayback) != null && f.call(y)));
|
|
671
681
|
} catch {
|
|
672
682
|
}
|
|
673
683
|
const c = this.omidRules();
|
|
@@ -686,9 +696,9 @@ class U {
|
|
|
686
696
|
var c, h;
|
|
687
697
|
const e = (c = this.ima) == null ? void 0 : c.OmidVerificationVendor, t = (h = this.ima) == null ? void 0 : h.OmidAccessMode;
|
|
688
698
|
if (!e || !t) return null;
|
|
689
|
-
const i = this.options.omidAccessMode ?? "full", s = (
|
|
690
|
-
for (const [
|
|
691
|
-
typeof u == "number" && (n[u] = s(a[
|
|
699
|
+
const i = this.options.omidAccessMode ?? "full", s = (l) => l === "full" ? t.FULL : l === "domain" ? t.DOMAIN : l === "limited" ? t.LIMITED : void 0, a = typeof i == "string" ? {} : i, o = s(typeof i == "string" ? i : i.default ?? "full") ?? t.FULL, n = {};
|
|
700
|
+
for (const [l, u] of Object.entries(e))
|
|
701
|
+
typeof u == "number" && (n[u] = s(a[l]) ?? o);
|
|
692
702
|
return n;
|
|
693
703
|
}
|
|
694
704
|
startAdsManager() {
|
|
@@ -746,14 +756,14 @@ class U {
|
|
|
746
756
|
}
|
|
747
757
|
/** IMA hatasının kodlarını çıkarır, hata kaydına yazar (yeniden denenecek olsa da) ve mesajı döndürür. */
|
|
748
758
|
recordAdError(e) {
|
|
749
|
-
var s, a, o, n, c, h,
|
|
759
|
+
var s, a, o, n, c, h, l;
|
|
750
760
|
const t = (s = e.getError) == null ? void 0 : s.call(e), i = {
|
|
751
761
|
message: ((a = t == null ? void 0 : t.getMessage) == null ? void 0 : a.call(t)) ?? "ad-error",
|
|
752
762
|
code: (o = t == null ? void 0 : t.getErrorCode) == null ? void 0 : o.call(t),
|
|
753
763
|
vastCode: (n = t == null ? void 0 : t.getVastErrorCode) == null ? void 0 : n.call(t),
|
|
754
764
|
errorType: (c = t == null ? void 0 : t.getType) == null ? void 0 : c.call(t)
|
|
755
765
|
};
|
|
756
|
-
return i.vastCode !== void 0 && i.vastCode <= 0 && (i.vastCode = void 0), this.lastAdError = i, (
|
|
766
|
+
return i.vastCode !== void 0 && i.vastCode <= 0 && (i.vastCode = void 0), this.lastAdError = i, (l = (h = this.ctx).log) == null || l.call(h, {
|
|
757
767
|
message: i.message,
|
|
758
768
|
details: { code: i.code, vastCode: i.vastCode, errorType: i.errorType, break: this.breakTypeLower() }
|
|
759
769
|
}), i.message;
|
|
@@ -803,7 +813,7 @@ class U {
|
|
|
803
813
|
this.vmapRequested || !this.options.adTagVmap || (this.vmapRequested = !0, this.requestAd("Midroll", this.options.adTagVmap, 0, !0));
|
|
804
814
|
}
|
|
805
815
|
hideAdLayer() {
|
|
806
|
-
this.nonLinearActive || (this.ctx.adLayerEl.classList.add("hp:hidden"), this.ctx.adLayerEl.classList.remove("hp:block")), this.ctx.showChrome();
|
|
816
|
+
this.ctx.adLayerEl.removeAttribute("data-audio-ad"), this.nonLinearActive || (this.ctx.adLayerEl.classList.add("hp:hidden"), this.ctx.adLayerEl.classList.remove("hp:block")), this.ctx.showChrome();
|
|
807
817
|
}
|
|
808
818
|
/**
|
|
809
819
|
* Başlayan aranın gerçek tipi. VMAP tek istekle preroll + midroll + postroll getirir; isteğin tipi (currentBreakType)
|
|
@@ -824,12 +834,12 @@ class U {
|
|
|
824
834
|
return this.currentBreakType.toLowerCase();
|
|
825
835
|
}
|
|
826
836
|
}
|
|
827
|
-
async function
|
|
828
|
-
const t = new U(
|
|
837
|
+
async function _(d, e) {
|
|
838
|
+
const t = new U(d, e);
|
|
829
839
|
return await t.install(), t;
|
|
830
840
|
}
|
|
831
841
|
export {
|
|
832
842
|
U as AdsController,
|
|
833
|
-
|
|
843
|
+
_ as installAds
|
|
834
844
|
};
|
|
835
|
-
//# sourceMappingURL=index-
|
|
845
|
+
//# sourceMappingURL=index-BCMVXNL0.js.map
|