@next2d/media 1.18.11 → 2.0.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.
Files changed (110) hide show
  1. package/README.md +2 -2
  2. package/package.json +13 -26
  3. package/src/MediaUtil.d.ts +104 -0
  4. package/src/MediaUtil.js +203 -0
  5. package/src/Sound/service/SoundDecodeService.d.ts +10 -0
  6. package/src/Sound/service/SoundDecodeService.js +30 -0
  7. package/src/Sound/service/SoundEndedEventService.d.ts +11 -0
  8. package/src/Sound/service/SoundEndedEventService.js +21 -0
  9. package/src/Sound/service/SoundLoadStartEventService.d.ts +12 -0
  10. package/src/Sound/service/SoundLoadStartEventService.js +19 -0
  11. package/src/Sound/service/SoundProgressEventService.d.ts +12 -0
  12. package/src/Sound/service/SoundProgressEventService.js +16 -0
  13. package/src/Sound/usecase/SoundBuildFromCharacterUseCase.d.ts +13 -0
  14. package/src/Sound/usecase/SoundBuildFromCharacterUseCase.js +23 -0
  15. package/src/Sound/usecase/SoundLoadEndEventUseCase.d.ts +12 -0
  16. package/src/Sound/usecase/SoundLoadEndEventUseCase.js +35 -0
  17. package/src/Sound/usecase/SoundLoadUseCase.d.ts +13 -0
  18. package/src/Sound/usecase/SoundLoadUseCase.js +38 -0
  19. package/src/Sound.d.ts +136 -0
  20. package/src/Sound.js +247 -0
  21. package/src/SoundMixer/service/SoundMixerStopAllService.d.ts +9 -0
  22. package/src/SoundMixer/service/SoundMixerStopAllService.js +32 -0
  23. package/src/SoundMixer/service/SoundMixerUpdateVolumeService.d.ts +9 -0
  24. package/src/SoundMixer/service/SoundMixerUpdateVolumeService.js +29 -0
  25. package/src/SoundMixer.d.ts +28 -0
  26. package/src/SoundMixer.js +37 -0
  27. package/src/SoundTransform.d.ts +35 -0
  28. package/src/SoundTransform.js +48 -0
  29. package/src/Video/service/VideoApplyChangesService.d.ts +11 -0
  30. package/src/Video/service/VideoApplyChangesService.js +16 -0
  31. package/src/Video/service/VideoCreateElementService.d.ts +9 -0
  32. package/src/Video/service/VideoCreateElementService.js +16 -0
  33. package/src/Video/service/VideoEndedEventService.d.ts +11 -0
  34. package/src/Video/service/VideoEndedEventService.js +22 -0
  35. package/src/Video/service/VideoLoadedmetadataEventService.d.ts +12 -0
  36. package/src/Video/service/VideoLoadedmetadataEventService.js +21 -0
  37. package/src/Video/service/VideoProgressEventService.d.ts +11 -0
  38. package/src/Video/service/VideoProgressEventService.js +15 -0
  39. package/src/Video/usecase/VideoBuildFromCharacterUseCase.d.ts +13 -0
  40. package/src/Video/usecase/VideoBuildFromCharacterUseCase.js +22 -0
  41. package/src/Video/usecase/VideoCanplaythroughEventUseCase.d.ts +11 -0
  42. package/src/Video/usecase/VideoCanplaythroughEventUseCase.js +26 -0
  43. package/src/Video/usecase/VideoPlayEventUseCase.d.ts +11 -0
  44. package/src/Video/usecase/VideoPlayEventUseCase.js +31 -0
  45. package/src/Video/usecase/VideoRegisterEventUseCase.d.ts +12 -0
  46. package/src/Video/usecase/VideoRegisterEventUseCase.js +29 -0
  47. package/src/Video.d.ts +245 -0
  48. package/src/Video.js +428 -0
  49. package/{dist → src}/index.d.ts +1 -0
  50. package/{dist → src}/index.js +1 -0
  51. package/src/interface/IAjaxEvent.d.ts +5 -0
  52. package/src/interface/IAjaxEvent.js +1 -0
  53. package/src/interface/IAjaxOption.d.ts +13 -0
  54. package/src/interface/IAjaxOption.js +1 -0
  55. package/src/interface/IBlendMode.d.ts +1 -0
  56. package/src/interface/IBlendMode.js +1 -0
  57. package/src/interface/IBounds.d.ts +6 -0
  58. package/src/interface/IBounds.js +1 -0
  59. package/src/interface/ICharacter.d.ts +5 -0
  60. package/src/interface/ICharacter.js +1 -0
  61. package/src/interface/IDictionaryTag.d.ts +8 -0
  62. package/src/interface/IDictionaryTag.js +1 -0
  63. package/src/interface/IFilterArray.d.ts +2 -0
  64. package/src/interface/IFilterArray.js +1 -0
  65. package/src/interface/IGrid.d.ts +6 -0
  66. package/src/interface/IGrid.js +1 -0
  67. package/src/interface/ILoopConfig.d.ts +8 -0
  68. package/src/interface/ILoopConfig.js +1 -0
  69. package/src/interface/ILoopType.d.ts +1 -0
  70. package/src/interface/ILoopType.js +1 -0
  71. package/src/interface/IMovieClipActionObject.d.ts +5 -0
  72. package/src/interface/IMovieClipActionObject.js +1 -0
  73. package/src/interface/IMovieClipCharacter.d.ts +17 -0
  74. package/src/interface/IMovieClipCharacter.js +1 -0
  75. package/src/interface/IMovieClipLabelObject.d.ts +4 -0
  76. package/src/interface/IMovieClipLabelObject.js +1 -0
  77. package/src/interface/IMovieClipSoundObject.d.ts +5 -0
  78. package/src/interface/IMovieClipSoundObject.js +1 -0
  79. package/src/interface/IPlaceObject.d.ts +14 -0
  80. package/src/interface/IPlaceObject.js +1 -0
  81. package/src/interface/IShapeCharacter.d.ts +14 -0
  82. package/src/interface/IShapeCharacter.js +1 -0
  83. package/src/interface/ISoundCharacter.d.ts +4 -0
  84. package/src/interface/ISoundCharacter.js +1 -0
  85. package/src/interface/ISoundTag.d.ts +6 -0
  86. package/src/interface/ISoundTag.js +1 -0
  87. package/src/interface/ISurfaceFilter.d.ts +6 -0
  88. package/src/interface/ISurfaceFilter.js +1 -0
  89. package/src/interface/ITextFieldCharacter.d.ts +26 -0
  90. package/src/interface/ITextFieldCharacter.js +1 -0
  91. package/src/interface/ITextFieldType.d.ts +1 -0
  92. package/src/interface/ITextFieldType.js +1 -0
  93. package/src/interface/ITextFormatAlign.d.ts +1 -0
  94. package/src/interface/ITextFormatAlign.js +1 -0
  95. package/src/interface/IURLLoaderDataFormat.d.ts +1 -0
  96. package/src/interface/IURLLoaderDataFormat.js +1 -0
  97. package/src/interface/IURLRequestHeader.d.ts +4 -0
  98. package/src/interface/IURLRequestHeader.js +1 -0
  99. package/src/interface/IURLRequestMethod.d.ts +1 -0
  100. package/src/interface/IURLRequestMethod.js +1 -0
  101. package/src/interface/IVideoCharacter.d.ts +11 -0
  102. package/src/interface/IVideoCharacter.js +1 -0
  103. package/dist/Sound.d.ts +0 -206
  104. package/dist/Sound.js +0 -501
  105. package/dist/SoundMixer.d.ts +0 -68
  106. package/dist/SoundMixer.js +0 -114
  107. package/dist/SoundTransform.d.ts +0 -80
  108. package/dist/SoundTransform.js +0 -111
  109. package/dist/Video.d.ts +0 -328
  110. package/dist/Video.js +0 -897
@@ -0,0 +1,22 @@
1
+ import { VideoEvent } from "@next2d/events";
2
+ /**
3
+ * @description ビデオが最終フレームに達したときの処理
4
+ * Processing when the video reaches the last frame
5
+ *
6
+ * @param {Video} video
7
+ * @return {void}
8
+ * @method
9
+ * @protected
10
+ */
11
+ export const execute = (video) => {
12
+ if (video.willTrigger(VideoEvent.ENDED)) {
13
+ video.dispatchEvent(new VideoEvent(VideoEvent.ENDED));
14
+ }
15
+ if (video.loop) {
16
+ video.currentTime = 0;
17
+ return;
18
+ }
19
+ video.ended = true;
20
+ video.changed = false;
21
+ video.pause();
22
+ };
@@ -0,0 +1,12 @@
1
+ import type { Video } from "../../Video";
2
+ /**
3
+ * @description Videoオブジェクトの幅と高さを更新する
4
+ * Update the width and height of the Video object
5
+ *
6
+ * @param {HTMLVideoElement} element
7
+ * @param {Video} video
8
+ * @return {void}
9
+ * @method
10
+ * @protected
11
+ */
12
+ export declare const execute: (element: HTMLVideoElement, video: Video) => void;
@@ -0,0 +1,21 @@
1
+ /**
2
+ * @description Videoオブジェクトの幅と高さを更新する
3
+ * Update the width and height of the Video object
4
+ *
5
+ * @param {HTMLVideoElement} element
6
+ * @param {Video} video
7
+ * @return {void}
8
+ * @method
9
+ * @protected
10
+ */
11
+ export const execute = (element, video) => {
12
+ // update metadata
13
+ video.currentTime = 0;
14
+ video.duration = element.duration;
15
+ video.videoWidth = element.videoWidth;
16
+ video.videoHeight = element.videoHeight;
17
+ // reset
18
+ const offscreenCanvas = new OffscreenCanvas(video.videoWidth, video.videoHeight);
19
+ video.$context = offscreenCanvas.getContext("2d");
20
+ video.$offscreenCanvas = offscreenCanvas;
21
+ };
@@ -0,0 +1,11 @@
1
+ import type { Video } from "../../Video";
2
+ /**
3
+ * @description ビデオ読み込み中の進捗状態の確認イベント処理関数
4
+ * Event processing function to check the progress status of video loading
5
+ *
6
+ * @param {Video} video
7
+ * @return {void}
8
+ * @method
9
+ * @protected
10
+ */
11
+ export declare const execute: (video: Video, event: ProgressEvent) => void;
@@ -0,0 +1,15 @@
1
+ import { ProgressEvent as Next2DProgressEvent } from "@next2d/events";
2
+ /**
3
+ * @description ビデオ読み込み中の進捗状態の確認イベント処理関数
4
+ * Event processing function to check the progress status of video loading
5
+ *
6
+ * @param {Video} video
7
+ * @return {void}
8
+ * @method
9
+ * @protected
10
+ */
11
+ export const execute = (video, event) => {
12
+ if (video.willTrigger(Next2DProgressEvent.PROGRESS)) {
13
+ video.dispatchEvent(new Next2DProgressEvent(Next2DProgressEvent.PROGRESS, false, event.loaded, event.total));
14
+ }
15
+ };
@@ -0,0 +1,13 @@
1
+ import type { Video } from "@next2d/media";
2
+ import type { IVideoCharacter } from "../../interface/IVideoCharacter";
3
+ /**
4
+ * @description characterを元にTextFieldを構築
5
+ * Build TextField based on character
6
+ *
7
+ * @param {Video} video
8
+ * @param {IVideoCharacter} character
9
+ * @return {void}
10
+ * @method
11
+ * @protected
12
+ */
13
+ export declare const execute: (video: Video, character: IVideoCharacter) => void;
@@ -0,0 +1,22 @@
1
+ /**
2
+ * @description characterを元にTextFieldを構築
3
+ * Build TextField based on character
4
+ *
5
+ * @param {Video} video
6
+ * @param {IVideoCharacter} character
7
+ * @return {void}
8
+ * @method
9
+ * @protected
10
+ */
11
+ export const execute = (video, character) => {
12
+ if (!character.videoData) {
13
+ character.videoData = new Uint8Array(character.buffer);
14
+ character.buffer = null;
15
+ }
16
+ video.loop = character.loop;
17
+ video.autoPlay = character.autoPlay;
18
+ video.videoWidth = character.bounds.xMax;
19
+ video.videoHeight = character.bounds.yMax;
20
+ video.volume = character.volume;
21
+ video.src = URL.createObjectURL(new Blob([character.videoData], { "type": "video/mp4" }));
22
+ };
@@ -0,0 +1,11 @@
1
+ import type { Video } from "../../Video";
2
+ /**
3
+ * @description 再生可能処理
4
+ * Playable processing
5
+ *
6
+ * @param {Video} video
7
+ * @return {Promise}
8
+ * @method
9
+ * @protected
10
+ */
11
+ export declare const execute: (video: Video) => Promise<void>;
@@ -0,0 +1,26 @@
1
+ import { Event } from "@next2d/events";
2
+ import { execute as videoApplyChangesService } from "../service/VideoApplyChangesService";
3
+ import { $isAudioContext, $pushMutedVideos } from "../../MediaUtil";
4
+ /**
5
+ * @description 再生可能処理
6
+ * Playable processing
7
+ *
8
+ * @param {Video} video
9
+ * @return {Promise}
10
+ * @method
11
+ * @protected
12
+ */
13
+ export const execute = async (video) => {
14
+ if (video.autoPlay) {
15
+ if (!$isAudioContext()) {
16
+ video.muted = true;
17
+ $pushMutedVideos(video);
18
+ }
19
+ await video.play();
20
+ }
21
+ video.loaded = true;
22
+ videoApplyChangesService(video);
23
+ if (video.willTrigger(Event.COMPLETE)) {
24
+ video.dispatchEvent(new Event(Event.COMPLETE));
25
+ }
26
+ };
@@ -0,0 +1,11 @@
1
+ import type { Video } from "../../Video";
2
+ /**
3
+ * @description ビデオ再生中のイベント処理関数
4
+ * Event processing function during video playback
5
+ *
6
+ * @param {Video} video
7
+ * @return {void}
8
+ * @method
9
+ * @protected
10
+ */
11
+ export declare const execute: (video: Video) => number;
@@ -0,0 +1,31 @@
1
+ import { $getPlayingVideos } from "../../MediaUtil";
2
+ import { VideoEvent } from "@next2d/events";
3
+ import { execute as videoApplyChangesService } from "../service/VideoApplyChangesService";
4
+ /**
5
+ * @description ビデオ再生中のイベント処理関数
6
+ * Event processing function during video playback
7
+ *
8
+ * @param {Video} video
9
+ * @return {void}
10
+ * @method
11
+ * @protected
12
+ */
13
+ export const execute = (video) => {
14
+ if (video.paused || !video.loaded) {
15
+ return 0;
16
+ }
17
+ if (video.willTrigger(VideoEvent.PLAY)) {
18
+ video.dispatchEvent(new VideoEvent(VideoEvent.PLAY));
19
+ }
20
+ videoApplyChangesService(video);
21
+ const playingVideos = $getPlayingVideos();
22
+ if (playingVideos.indexOf(video) === -1) {
23
+ playingVideos.push(video);
24
+ }
25
+ if (video.$context && video.$videoElement) {
26
+ video.$context.drawImage(video.$videoElement, 0, 0, video.videoWidth, video.videoHeight);
27
+ }
28
+ return requestAnimationFrame(() => {
29
+ execute(video);
30
+ });
31
+ };
@@ -0,0 +1,12 @@
1
+ import type { Video } from "../../Video";
2
+ /**
3
+ * @description HTMLVideoElementにイベントを登録する
4
+ * Register events on HTMLVideoElement
5
+ *
6
+ * @param {HTMLVideoElement} element
7
+ * @param {Video} video
8
+ * @return {void}
9
+ * @method
10
+ * @protected
11
+ */
12
+ export declare const execute: (element: HTMLVideoElement, video: Video) => void;
@@ -0,0 +1,29 @@
1
+ import { execute as videoCanplaythroughEventUseCase } from "./VideoCanplaythroughEventUseCase";
2
+ import { execute as videoLoadedmetadataEventService } from "../service/VideoLoadedmetadataEventService";
3
+ import { execute as videoProgressEventService } from "../service/VideoProgressEventService";
4
+ import { execute as videoEndedEventService } from "../service/VideoEndedEventService";
5
+ /**
6
+ * @description HTMLVideoElementにイベントを登録する
7
+ * Register events on HTMLVideoElement
8
+ *
9
+ * @param {HTMLVideoElement} element
10
+ * @param {Video} video
11
+ * @return {void}
12
+ * @method
13
+ * @protected
14
+ */
15
+ export const execute = (element, video) => {
16
+ element.addEventListener("loadedmetadata", () => {
17
+ videoLoadedmetadataEventService(element, video);
18
+ }, { "once": true });
19
+ element.addEventListener("progress", (event) => {
20
+ videoProgressEventService(video, event);
21
+ });
22
+ element.addEventListener("canplaythrough", async () => {
23
+ await videoCanplaythroughEventUseCase(video);
24
+ element.volume = video.volume;
25
+ }, { "once": true });
26
+ element.addEventListener("ended", () => {
27
+ videoEndedEventService(video);
28
+ });
29
+ };
package/src/Video.d.ts ADDED
@@ -0,0 +1,245 @@
1
+ import type { ICharacter } from "./interface/ICharacter";
2
+ import type { LoaderInfo } from "@next2d/display";
3
+ import { DisplayObject } from "@next2d/display";
4
+ /**
5
+ * @description サーバーまたはローカルに保存された録画済みビデオファイルを再生する Video オブジェクトです。
6
+ * ビデオストリームを再生するには、attachNetStream() を使用して、ビデオを Video オブジェクトに関連付けます。
7
+ * 次に、addChild() を使用して、Video オブジェクトを表示リストに追加します。
8
+ * A Video object that plays a recorded video file stored on a server or locally.
9
+ * To play a video stream, use attachNetStream() to attach the video to the Video object.
10
+ * Then, add the Video object to the display list using addChild().
11
+ *
12
+ * @class
13
+ * @memberOf next2d.media
14
+ * @extends DisplayObject
15
+ */
16
+ export declare class Video extends DisplayObject {
17
+ /**
18
+ * @description キーフレーム総数
19
+ * Total number of keyframes
20
+ *
21
+ * @type {number}
22
+ * @default 0
23
+ * @public
24
+ */
25
+ duration: number;
26
+ /**
27
+ * @description ビデオを拡大 / 縮小する際にスムージング(補間)するかどうかを指定します。
28
+ * Specifies whether the video should be smoothed (interpolated)
29
+ * when it is scaled.
30
+ *
31
+ * @type {boolean}
32
+ * @default true
33
+ * @public
34
+ */
35
+ smoothing: boolean;
36
+ /**
37
+ * @description ビデオをループ生成するかどうかを指定します。
38
+ * Specifies whether to generate a video loop.
39
+ *
40
+ * @type {boolean}
41
+ * @default false
42
+ * @public
43
+ */
44
+ loop: boolean;
45
+ /**
46
+ * @description ビデオの自動再生の設定。
47
+ * Setting up automatic video playback.
48
+ *
49
+ * @type {boolean}
50
+ * @default true
51
+ * @public
52
+ */
53
+ autoPlay: boolean;
54
+ /**
55
+ * @description 現在のキーフレーム
56
+ * Current keyframe
57
+ *
58
+ *
59
+ * @member {number}
60
+ * @public
61
+ */
62
+ currentTime: number;
63
+ /**
64
+ * @description ビデオの幅をピクセル単位で指定する整数です。
65
+ * An integer specifying the width of the video, in pixels.
66
+ *
67
+ * @member {number}
68
+ * @default 0
69
+ * @public
70
+ */
71
+ videoWidth: number;
72
+ /**
73
+ * @description ビデオの高さをピクセル単位で指定する整数です。
74
+ * An integer specifying the height of the video, in pixels.
75
+ *
76
+ * @member {number}
77
+ * @default 0
78
+ * @public
79
+ */
80
+ videoHeight: number;
81
+ /**
82
+ * @description ビデオが読み込まれているかどうかを返します。
83
+ * Returns whether the video has been loaded.
84
+ *
85
+ * @type {boolean}
86
+ * @default false
87
+ * @public
88
+ */
89
+ loaded: boolean;
90
+ /**
91
+ * @description ビデオが終了したかどうかを返します。
92
+ * Returns whether the video has ended.
93
+ *
94
+ * @type {boolean}
95
+ * @default false
96
+ * @public
97
+ */
98
+ ended: boolean;
99
+ /**
100
+ * @description Videoの機能を所持しているかを返却
101
+ * Returns whether the display object has Video functionality.
102
+ *
103
+ * @type {boolean}
104
+ * @readonly
105
+ * @public
106
+ */
107
+ readonly isVideo: boolean;
108
+ /**
109
+ * @type {HTMLVideoElement}
110
+ * @default null
111
+ * @public
112
+ */
113
+ $videoElement: HTMLVideoElement | null;
114
+ /**
115
+ * @type {OffscreenCanvas}
116
+ * @default null
117
+ * @public
118
+ */
119
+ $offscreenCanvas: OffscreenCanvas | null;
120
+ /**
121
+ * @type {OffscreenCanvasRenderingContext2D}
122
+ * @default null
123
+ * @public
124
+ */
125
+ $context: OffscreenCanvasRenderingContext2D | null;
126
+ /**
127
+ * @type {boolean}
128
+ * @default true
129
+ * @public
130
+ */
131
+ paused: boolean;
132
+ /**
133
+ * @type {number}
134
+ * @default -1
135
+ * @private
136
+ */
137
+ private _$timerId;
138
+ /**
139
+ * @type {number}
140
+ * @default 1
141
+ * @private
142
+ */
143
+ private _$volume;
144
+ /**
145
+ * @type {string}
146
+ * @default ""
147
+ * @private
148
+ */
149
+ private _$src;
150
+ /**
151
+ * @param {number} [width = 0]
152
+ * @param {number} [height = 0]
153
+ *
154
+ * @constructor
155
+ * @public
156
+ */
157
+ constructor(width?: number, height?: number);
158
+ /**
159
+ * @description 指定されたクラスの空間名を返します。
160
+ * Returns the space name of the specified class.
161
+ *
162
+ * @return {string}
163
+ * @const
164
+ * @static
165
+ */
166
+ static get namespace(): string;
167
+ /**
168
+ * @description 指定されたオブジェクトの空間名を返します。
169
+ * Returns the space name of the specified object.
170
+ *
171
+ * @return {string}
172
+ * @const
173
+ * @public
174
+ */
175
+ get namespace(): string;
176
+ /**
177
+ * @description ビデオコンテンツへの URL を指定します。
178
+ * Specifies the URL of the video content.
179
+ *
180
+ * @member {string}
181
+ * @default ""
182
+ * @public
183
+ */
184
+ get src(): string;
185
+ set src(src: string);
186
+ /**
187
+ * @description ビデオがミュートされているかどうかを返します。
188
+ * Returns whether the video is muted.
189
+ *
190
+ * @member {boolean}
191
+ * @default false
192
+ * @public
193
+ */
194
+ get muted(): boolean;
195
+ set muted(muted: boolean);
196
+ /**
197
+ * @description ボリュームです。範囲は 0(無音)~ 1(フルボリューム)です。
198
+ * The volume, ranging from 0 (silent) to 1 (full volume).
199
+ *
200
+ * @member {number}
201
+ * @default 1
202
+ * @public
203
+ */
204
+ get volume(): number;
205
+ set volume(volume: number);
206
+ /**
207
+ * @description ビデオの再生を一時停止します。
208
+ * Pauses the video playback.
209
+ *
210
+ * @return {void}
211
+ * @method
212
+ * @public
213
+ */
214
+ pause(): void;
215
+ /**
216
+ * @description ビデオファイルを再生します。
217
+ * Plays the video file.
218
+ *
219
+ * @returns {void}
220
+ * @method
221
+ * @public
222
+ */
223
+ play(): Promise<void>;
224
+ /**
225
+ * @description 指定された位置に最も近いキーフレームをシークします。
226
+ * Seeks the keyframe closest to the specified location.
227
+ *
228
+ * @param {number} offset
229
+ * @return {void}
230
+ * @method
231
+ * @public
232
+ */
233
+ seek(offset: number): void;
234
+ /**
235
+ * @description character 情報を元に DisplayObject を構築
236
+ * Build DisplayObject based on character
237
+ *
238
+ * @param {ICharacter} character
239
+ * @param {LoaderInfo} [loader_info=null]
240
+ * @return {void}
241
+ * @method
242
+ * @protected
243
+ */
244
+ $sync(character: ICharacter, loader_info?: LoaderInfo | null): void;
245
+ }