@flowplayer/spins 0.5.0 → 0.6.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/README.md +7 -36
- package/dist/index.js +28 -31
- package/dist/types.d.ts +176 -22
- package/package.json +1 -1
package/dist/types.d.ts
CHANGED
|
@@ -1,17 +1,67 @@
|
|
|
1
1
|
import { Config } from '@flowplayer/player';
|
|
2
|
-
import { PlayerIMAConfig } from '@flowplayer/player/plugins/ads';
|
|
2
|
+
import { PlayerIMAConfig, AdBreakCompletedEventDetail, AdCompletedEventDetail, AdBasicInfo, AdPlaybackErrorEventDetail, AdPrerollFinishedEventDetail, AdProgressEventDetail, AdRequestErrorEventDetail, AdResumedEventDetail, AdStartedEventDetail, AdTearDownEventDetail, AdSkippedEventDetail, AdMutedEventDetail, AdVolumeChangedEventDetail, AdsPlayer } from '@flowplayer/player/plugins/ads';
|
|
3
3
|
import { ConsentConfig } from '@flowplayer/player/plugins/consent';
|
|
4
4
|
import { ShareConfig } from '@flowplayer/player/plugins/share';
|
|
5
5
|
import { SubtitlesConfig } from '@flowplayer/player/plugins/subtitles';
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
7
|
+
declare const spinEvents: {
|
|
8
|
+
/**
|
|
9
|
+
* Emitted when a new spin is created.
|
|
10
|
+
*/
|
|
11
|
+
readonly SPIN_CREATED: "spin:created";
|
|
12
|
+
/**
|
|
13
|
+
* Emitted when a different spin enters the viewport.
|
|
14
|
+
*/
|
|
15
|
+
readonly SPIN_IN_VIEWPORT: "spin:viewport";
|
|
16
|
+
};
|
|
17
|
+
declare const mediaEvents: {
|
|
18
|
+
/** Fired when the browser can start playing the media without stopping for buffering. */
|
|
19
|
+
readonly CAN_PLAY: "canplay";
|
|
20
|
+
/** Fired when the playback position changes (e.g. during playback or scrubbing). */
|
|
21
|
+
readonly TIME_UPDATE: "timeupdate";
|
|
22
|
+
/** Fired when playback is actively progressing after being paused or buffering. */
|
|
23
|
+
readonly PLAYING: "playing";
|
|
24
|
+
/** Fired when playback is delayed while the next frame is being loaded (buffering). */
|
|
25
|
+
readonly WAITING: "waiting";
|
|
26
|
+
/** Fired when playback has been paused by the user or programmatically. */
|
|
27
|
+
readonly PAUSE: "pause";
|
|
28
|
+
/** Fired when playback has been started or resumed. */
|
|
29
|
+
readonly PLAY: "play";
|
|
30
|
+
/** Fired when the user begins seeking to a new playback position. */
|
|
31
|
+
readonly SEEKING: "seeking";
|
|
32
|
+
/** Fired when playback has reached the end of the media resource. */
|
|
33
|
+
readonly ENDED: "ended";
|
|
34
|
+
};
|
|
35
|
+
declare const adEvents: {
|
|
36
|
+
/** Fired when the ad teardown/cleanup process occurs. */
|
|
37
|
+
readonly AD_TEARDOWN: "ad-teardown";
|
|
38
|
+
/** Fired when a single ad has finished playing. */
|
|
39
|
+
readonly AD_COMPLETED: "ad-completed";
|
|
40
|
+
/** Fired when an ad request fails due to a network or server error. */
|
|
41
|
+
readonly AD_REQUEST_ERROR: "ad-request-error";
|
|
42
|
+
/** Fired when an ad was received and starts playing. */
|
|
43
|
+
readonly AD_STARTED: "ad-started";
|
|
44
|
+
/** Internal or general ad error event. */
|
|
45
|
+
readonly AD_ERROR: "ad-error";
|
|
46
|
+
/** Fired when an ad request succeeds but the ad fails to play. */
|
|
47
|
+
readonly AD_PLAYBACK_ERROR: "ad-playback-error";
|
|
48
|
+
/** Fired when an ad break (a group of ads) has completed. */
|
|
49
|
+
readonly AD_BREAK_COMPLETED: "ad-break-completed";
|
|
50
|
+
/** Fired periodically as the ad progresses during playback. */
|
|
51
|
+
readonly AD_PROGRESS: "ad-progress";
|
|
52
|
+
/** Fired when an ad is paused. */
|
|
53
|
+
readonly AD_PAUSED: "ad-paused";
|
|
54
|
+
/** Fired when an ad resumes after being paused. */
|
|
55
|
+
readonly AD_RESUMED: "ad-resumed";
|
|
56
|
+
/** Fired when preroll playback (and possible postroll) is finished. */
|
|
57
|
+
readonly AD_PREROLL_FINSIHED: "ad-preroll-finished";
|
|
58
|
+
/** Fired when the skip button is clicked and the ad is skipped. */
|
|
59
|
+
readonly AD_SKIPPED: "ad-skipped";
|
|
60
|
+
/** Fired when the ad has been muted. */
|
|
61
|
+
readonly AD_MUTED: "ad-muted";
|
|
62
|
+
/** Fired when the ad volume changes during playback. */
|
|
63
|
+
readonly AD_VOLUME_CHANGED: "ad-volume-changed";
|
|
64
|
+
};
|
|
15
65
|
|
|
16
66
|
/**
|
|
17
67
|
* All supported plugin identifiers for configuring the player.
|
|
@@ -107,32 +157,136 @@ type SpinEventData = {
|
|
|
107
157
|
*/
|
|
108
158
|
index: number;
|
|
109
159
|
};
|
|
160
|
+
type MediaEventData = {
|
|
161
|
+
/**
|
|
162
|
+
* the index of the spin
|
|
163
|
+
*/
|
|
164
|
+
spinIndex: number;
|
|
165
|
+
/**
|
|
166
|
+
* the length of the video in seconds
|
|
167
|
+
*/
|
|
168
|
+
duration?: number;
|
|
169
|
+
/**
|
|
170
|
+
* the current playback time in seconds
|
|
171
|
+
*/
|
|
172
|
+
currentTime: number;
|
|
173
|
+
/**
|
|
174
|
+
* the mediaId
|
|
175
|
+
*/
|
|
176
|
+
mediaId?: string;
|
|
177
|
+
/**
|
|
178
|
+
* the full url of the media that is being played
|
|
179
|
+
*/
|
|
180
|
+
url: string;
|
|
181
|
+
};
|
|
182
|
+
type AdEventData<K extends AdEvent> = {
|
|
183
|
+
spinIndex: number;
|
|
184
|
+
} & AdEventsDetailMap[K];
|
|
185
|
+
type SpinsAdPlayerConfig = {
|
|
186
|
+
poster?: Config["poster"];
|
|
187
|
+
/**
|
|
188
|
+
* Consent plugin configuration. A bitmask property where the possible values can be found from `Consent.tracking` and `Consent.storage` enumerations.
|
|
189
|
+
* @see https://developer.wowza.com/docs/wowza-flowplayer/plugins/consent/
|
|
190
|
+
*/
|
|
191
|
+
consent?: ConsentConfig["consent"];
|
|
192
|
+
/**
|
|
193
|
+
* Sets the language of your preference.
|
|
194
|
+
* @default english
|
|
195
|
+
* @see https://developer.wowza.com/docs/wowza-flowplayer/player/translations/#configure-translations
|
|
196
|
+
*/
|
|
197
|
+
lang?: Config["lang"];
|
|
198
|
+
/**
|
|
199
|
+
* Your token.
|
|
200
|
+
* @see https://developer.wowza.com/docs/wowza-flowplayer/player/configure/#token-configuration
|
|
201
|
+
*/
|
|
202
|
+
token: string;
|
|
203
|
+
/**
|
|
204
|
+
* Ads configuration
|
|
205
|
+
* @see https://developer.wowza.com/docs/wowza-flowplayer/plugins/advertising/#ima-object-configuration
|
|
206
|
+
*/
|
|
207
|
+
ima: PlayerIMAConfig;
|
|
208
|
+
};
|
|
209
|
+
type SpinEvent = (typeof spinEvents)[keyof typeof spinEvents];
|
|
210
|
+
type MediaEvent = (typeof mediaEvents)[keyof typeof mediaEvents];
|
|
211
|
+
type AdEvent = (typeof adEvents)[keyof typeof adEvents];
|
|
212
|
+
type PlayerEvent = MediaEvent | AdEvent;
|
|
213
|
+
type PlayerEventsDetailMap = {
|
|
214
|
+
[K in MediaEvent]: MediaEventData;
|
|
215
|
+
} & {
|
|
216
|
+
[K in AdEvent]: AdEventData<K>;
|
|
217
|
+
};
|
|
218
|
+
type AdEventsDetailMap = {
|
|
219
|
+
[adEvents.AD_BREAK_COMPLETED]: AdBreakCompletedEventDetail;
|
|
220
|
+
[adEvents.AD_COMPLETED]: AdCompletedEventDetail;
|
|
221
|
+
[adEvents.AD_ERROR]: AdBasicInfo;
|
|
222
|
+
[adEvents.AD_PAUSED]: AdBasicInfo;
|
|
223
|
+
[adEvents.AD_PLAYBACK_ERROR]: AdPlaybackErrorEventDetail;
|
|
224
|
+
[adEvents.AD_PREROLL_FINSIHED]: AdPrerollFinishedEventDetail;
|
|
225
|
+
[adEvents.AD_PROGRESS]: AdProgressEventDetail;
|
|
226
|
+
[adEvents.AD_REQUEST_ERROR]: AdRequestErrorEventDetail;
|
|
227
|
+
[adEvents.AD_RESUMED]: AdResumedEventDetail;
|
|
228
|
+
[adEvents.AD_STARTED]: AdStartedEventDetail;
|
|
229
|
+
[adEvents.AD_TEARDOWN]: AdTearDownEventDetail;
|
|
230
|
+
[adEvents.AD_SKIPPED]: AdSkippedEventDetail;
|
|
231
|
+
[adEvents.AD_MUTED]: AdMutedEventDetail;
|
|
232
|
+
[adEvents.AD_VOLUME_CHANGED]: AdVolumeChangedEventDetail;
|
|
233
|
+
};
|
|
110
234
|
interface SpinsContainer extends HTMLElement {
|
|
111
235
|
/**
|
|
112
|
-
* Adds a listener for
|
|
236
|
+
* Adds a listener for any player event (media or ad).
|
|
113
237
|
*/
|
|
114
|
-
|
|
238
|
+
onPlayerEvent<K extends PlayerEvent>(e: K, handler: (event: CustomEvent<PlayerEventsDetailMap[K]>) => void): void;
|
|
115
239
|
/**
|
|
116
|
-
* Adds a listener for
|
|
240
|
+
* Adds a listener for a SpinEvent.
|
|
117
241
|
*/
|
|
118
|
-
on(e:
|
|
242
|
+
on(e: SpinEvent, handler: (e: CustomEvent<SpinEventData>) => void, options?: boolean | AddEventListenerOptions): void;
|
|
119
243
|
/**
|
|
120
|
-
* Removes a listener for
|
|
244
|
+
* Removes a listener for a SpinEvent
|
|
121
245
|
*/
|
|
122
|
-
off(e:
|
|
246
|
+
off(e: SpinEvent, handler: (e?: CustomEvent<SpinEventData>) => void): void;
|
|
123
247
|
/**
|
|
124
|
-
* Removes a listener for
|
|
248
|
+
* Removes a listener for any player event (media or ad).
|
|
125
249
|
*/
|
|
126
|
-
|
|
250
|
+
offPlayerEvent<K extends PlayerEvent>(e: K, handler: (event: CustomEvent<PlayerEventsDetailMap[K]>) => void): void;
|
|
127
251
|
/**
|
|
128
252
|
* Add more spins dynamically.
|
|
129
253
|
*/
|
|
130
254
|
addSpins(spins: SpinItem[]): void;
|
|
131
255
|
}
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
256
|
+
|
|
257
|
+
interface SpinsAdPlayer extends HTMLElement {
|
|
258
|
+
/**
|
|
259
|
+
* The underlying ad player instance.
|
|
260
|
+
* Use this to listen to ad-related events directly.
|
|
261
|
+
*
|
|
262
|
+
* @see https://developer.wowza.com/docs/wowza-flowplayer/plugins/advertising/#listen-to-plugin-events
|
|
263
|
+
*/
|
|
264
|
+
player: AdsPlayer;
|
|
265
|
+
/**
|
|
266
|
+
* Immediately terminates the component’s lifecycle by cleaning up
|
|
267
|
+
* all resources and removing it from the DOM.
|
|
268
|
+
*
|
|
269
|
+
* Use this when you want to stop playback and dispose of the component
|
|
270
|
+
* early, instead of letting it be removed automatically at the natural
|
|
271
|
+
* end of the ad lifecycle.
|
|
272
|
+
*
|
|
273
|
+
* Once destroyed, the instance should not be reused.
|
|
274
|
+
*/
|
|
275
|
+
destroy(): void;
|
|
276
|
+
/**
|
|
277
|
+
* Requests and begins loading the ad into the player.
|
|
278
|
+
*/
|
|
279
|
+
loadAd(): void;
|
|
280
|
+
/**
|
|
281
|
+
* Registers a callback to be executed immediately before the component
|
|
282
|
+
* is destroyed and removed from the DOM.
|
|
283
|
+
*
|
|
284
|
+
* The callback is guaranteed to be invoked only once, and after it
|
|
285
|
+
* runs the instance should be considered invalid — it must not be reused.
|
|
286
|
+
*/
|
|
287
|
+
onBeforeDestroy(callback: () => void): void;
|
|
288
|
+
}
|
|
136
289
|
declare function createSpins(config: SpinsConfig): SpinsContainer;
|
|
290
|
+
declare function createAdPlayer(config: SpinsAdPlayerConfig): SpinsAdPlayer | void;
|
|
137
291
|
|
|
138
|
-
export { type SpinEventData, type SpinItem, type SpinsConfig, type SpinsContainer, createSpins,
|
|
292
|
+
export { type AdEvent, type AdEventData, type AdEventsDetailMap, type MediaEvent, type MediaEventData, type PlayerEvent, type PlayerEventsDetailMap, type SpinEvent, type SpinEventData, type SpinItem, type SpinsAdPlayer, type SpinsAdPlayerConfig, type SpinsConfig, type SpinsContainer, adEvents, createAdPlayer, createSpins, mediaEvents, spinEvents };
|