1 | import { BaseImageResource } from './BaseImageResource';
|
2 | import type { Dict } from '@pixi/utils';
|
3 | export interface IVideoResourceOptions {
|
4 | autoLoad?: boolean;
|
5 | autoPlay?: boolean;
|
6 | updateFPS?: number;
|
7 | crossorigin?: boolean | string;
|
8 | }
|
9 | export interface IVideoResourceOptionsElement {
|
10 | src: string;
|
11 | mime: string;
|
12 | }
|
13 | /**
|
14 | * Resource type for {@link HTMLVideoElement}.
|
15 | * @memberof PIXI
|
16 | */
|
17 | export declare class VideoResource extends BaseImageResource {
|
18 | /** Override the source to be the video element. */
|
19 | source: HTMLVideoElement;
|
20 | /**
|
21 | * `true` to use Ticker.shared to auto update the base texture.
|
22 | * @default true
|
23 | */
|
24 | protected _autoUpdate: boolean;
|
25 | /**
|
26 | * `true` if the instance is currently connected to PIXI.Ticker.shared to auto update the base texture.
|
27 | * @default false
|
28 | */
|
29 | protected _isConnectedToTicker: boolean;
|
30 | protected _updateFPS: number;
|
31 | protected _msToNextUpdate: number;
|
32 | /**
|
33 | * When set to true will automatically play videos used by this texture once
|
34 | * they are loaded. If false, it will not modify the playing state.
|
35 | * @default true
|
36 | */
|
37 | protected autoPlay: boolean;
|
38 | /**
|
39 | * Promise when loading.
|
40 | * @default null
|
41 | */
|
42 | private _load;
|
43 | /** Callback when completed with load. */
|
44 | private _resolve;
|
45 | /**
|
46 | * @param {HTMLVideoElement|object|string|Array<string|object>} source - Video element to use.
|
47 | * @param {object} [options] - Options to use
|
48 | * @param {boolean} [options.autoLoad=true] - Start loading the video immediately
|
49 | * @param {boolean} [options.autoPlay=true] - Start playing video immediately
|
50 | * @param {number} [options.updateFPS=0] - How many times a second to update the texture from the video.
|
51 | * Leave at 0 to update at every render.
|
52 | * @param {boolean} [options.crossorigin=true] - Load image using cross origin
|
53 | */
|
54 | constructor(source?: HTMLVideoElement | Array<string | IVideoResourceOptionsElement> | string, options?: IVideoResourceOptions);
|
55 | /**
|
56 | * Trigger updating of the texture.
|
57 | * @param _deltaTime - time delta since last tick
|
58 | */
|
59 | update(_deltaTime?: number): void;
|
60 | /**
|
61 | * Start preloading the video resource.
|
62 | * @returns {Promise<void>} Handle the validate event
|
63 | */
|
64 | load(): Promise<VideoResource>;
|
65 | /**
|
66 | * Handle video error events.
|
67 | * @param event
|
68 | */
|
69 | private _onError;
|
70 | /**
|
71 | * Returns true if the underlying source is playing.
|
72 | * @returns - True if playing.
|
73 | */
|
74 | private _isSourcePlaying;
|
75 | /**
|
76 | * Returns true if the underlying source is ready for playing.
|
77 | * @returns - True if ready.
|
78 | */
|
79 | private _isSourceReady;
|
80 | /** Runs the update loop when the video is ready to play. */
|
81 | private _onPlayStart;
|
82 | /** Fired when a pause event is triggered, stops the update loop. */
|
83 | private _onPlayStop;
|
84 | /** Fired when the video is loaded and ready to play. */
|
85 | private _onCanPlay;
|
86 | /** Destroys this texture. */
|
87 | dispose(): void;
|
88 | /** Should the base texture automatically update itself, set to true by default. */
|
89 | get autoUpdate(): boolean;
|
90 | set autoUpdate(value: boolean);
|
91 | /**
|
92 | * How many times a second to update the texture from the video. Leave at 0 to update at every render.
|
93 | * A lower fps can help performance, as updating the texture at 60fps on a 30ps video may not be efficient.
|
94 | */
|
95 | get updateFPS(): number;
|
96 | set updateFPS(value: number);
|
97 | /**
|
98 | * Used to auto-detect the type of resource.
|
99 | * @param {*} source - The source object
|
100 | * @param {string} extension - The extension of source, if set
|
101 | * @returns {boolean} `true` if video source
|
102 | */
|
103 | static test(source: unknown, extension?: string): source is HTMLVideoElement;
|
104 | /**
|
105 | * List of common video file extensions supported by VideoResource.
|
106 | * @readonly
|
107 | */
|
108 | static TYPES: Array<string>;
|
109 | /**
|
110 | * Map of video MIME types that can't be directly derived from file extensions.
|
111 | * @readonly
|
112 | */
|
113 | static MIME_TYPES: Dict<string>;
|
114 | }
|