@next2d/media 1.18.12 → 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.
- package/README.md +2 -2
- package/package.json +13 -26
- package/src/MediaUtil.d.ts +104 -0
- package/src/MediaUtil.js +203 -0
- package/src/Sound/service/SoundDecodeService.d.ts +10 -0
- package/src/Sound/service/SoundDecodeService.js +30 -0
- package/src/Sound/service/SoundEndedEventService.d.ts +11 -0
- package/src/Sound/service/SoundEndedEventService.js +21 -0
- package/src/Sound/service/SoundLoadStartEventService.d.ts +12 -0
- package/src/Sound/service/SoundLoadStartEventService.js +19 -0
- package/src/Sound/service/SoundProgressEventService.d.ts +12 -0
- package/src/Sound/service/SoundProgressEventService.js +16 -0
- package/src/Sound/usecase/SoundBuildFromCharacterUseCase.d.ts +13 -0
- package/src/Sound/usecase/SoundBuildFromCharacterUseCase.js +23 -0
- package/src/Sound/usecase/SoundLoadEndEventUseCase.d.ts +12 -0
- package/src/Sound/usecase/SoundLoadEndEventUseCase.js +35 -0
- package/src/Sound/usecase/SoundLoadUseCase.d.ts +13 -0
- package/src/Sound/usecase/SoundLoadUseCase.js +38 -0
- package/src/Sound.d.ts +136 -0
- package/src/Sound.js +247 -0
- package/src/SoundMixer/service/SoundMixerStopAllService.d.ts +9 -0
- package/src/SoundMixer/service/SoundMixerStopAllService.js +32 -0
- package/src/SoundMixer/service/SoundMixerUpdateVolumeService.d.ts +9 -0
- package/src/SoundMixer/service/SoundMixerUpdateVolumeService.js +29 -0
- package/src/SoundMixer.d.ts +28 -0
- package/src/SoundMixer.js +37 -0
- package/src/SoundTransform.d.ts +35 -0
- package/src/SoundTransform.js +48 -0
- package/src/Video/service/VideoApplyChangesService.d.ts +11 -0
- package/src/Video/service/VideoApplyChangesService.js +16 -0
- package/src/Video/service/VideoCreateElementService.d.ts +9 -0
- package/src/Video/service/VideoCreateElementService.js +16 -0
- package/src/Video/service/VideoEndedEventService.d.ts +11 -0
- package/src/Video/service/VideoEndedEventService.js +22 -0
- package/src/Video/service/VideoLoadedmetadataEventService.d.ts +12 -0
- package/src/Video/service/VideoLoadedmetadataEventService.js +21 -0
- package/src/Video/service/VideoProgressEventService.d.ts +11 -0
- package/src/Video/service/VideoProgressEventService.js +15 -0
- package/src/Video/usecase/VideoBuildFromCharacterUseCase.d.ts +13 -0
- package/src/Video/usecase/VideoBuildFromCharacterUseCase.js +22 -0
- package/src/Video/usecase/VideoCanplaythroughEventUseCase.d.ts +11 -0
- package/src/Video/usecase/VideoCanplaythroughEventUseCase.js +26 -0
- package/src/Video/usecase/VideoPlayEventUseCase.d.ts +11 -0
- package/src/Video/usecase/VideoPlayEventUseCase.js +31 -0
- package/src/Video/usecase/VideoRegisterEventUseCase.d.ts +12 -0
- package/src/Video/usecase/VideoRegisterEventUseCase.js +29 -0
- package/src/Video.d.ts +245 -0
- package/src/Video.js +428 -0
- package/{dist → src}/index.d.ts +1 -0
- package/{dist → src}/index.js +1 -0
- package/src/interface/IAjaxEvent.d.ts +5 -0
- package/src/interface/IAjaxEvent.js +1 -0
- package/src/interface/IAjaxOption.d.ts +13 -0
- package/src/interface/IAjaxOption.js +1 -0
- package/src/interface/IBlendMode.d.ts +1 -0
- package/src/interface/IBlendMode.js +1 -0
- package/src/interface/IBounds.d.ts +6 -0
- package/src/interface/IBounds.js +1 -0
- package/src/interface/ICharacter.d.ts +5 -0
- package/src/interface/ICharacter.js +1 -0
- package/src/interface/IDictionaryTag.d.ts +8 -0
- package/src/interface/IDictionaryTag.js +1 -0
- package/src/interface/IFilterArray.d.ts +2 -0
- package/src/interface/IFilterArray.js +1 -0
- package/src/interface/IGrid.d.ts +6 -0
- package/src/interface/IGrid.js +1 -0
- package/src/interface/ILoopConfig.d.ts +8 -0
- package/src/interface/ILoopConfig.js +1 -0
- package/src/interface/ILoopType.d.ts +1 -0
- package/src/interface/ILoopType.js +1 -0
- package/src/interface/IMovieClipActionObject.d.ts +5 -0
- package/src/interface/IMovieClipActionObject.js +1 -0
- package/src/interface/IMovieClipCharacter.d.ts +17 -0
- package/src/interface/IMovieClipCharacter.js +1 -0
- package/src/interface/IMovieClipLabelObject.d.ts +4 -0
- package/src/interface/IMovieClipLabelObject.js +1 -0
- package/src/interface/IMovieClipSoundObject.d.ts +5 -0
- package/src/interface/IMovieClipSoundObject.js +1 -0
- package/src/interface/IPlaceObject.d.ts +14 -0
- package/src/interface/IPlaceObject.js +1 -0
- package/src/interface/IShapeCharacter.d.ts +14 -0
- package/src/interface/IShapeCharacter.js +1 -0
- package/src/interface/ISoundCharacter.d.ts +4 -0
- package/src/interface/ISoundCharacter.js +1 -0
- package/src/interface/ISoundTag.d.ts +6 -0
- package/src/interface/ISoundTag.js +1 -0
- package/src/interface/ISurfaceFilter.d.ts +6 -0
- package/src/interface/ISurfaceFilter.js +1 -0
- package/src/interface/ITextFieldCharacter.d.ts +26 -0
- package/src/interface/ITextFieldCharacter.js +1 -0
- package/src/interface/ITextFieldType.d.ts +1 -0
- package/src/interface/ITextFieldType.js +1 -0
- package/src/interface/ITextFormatAlign.d.ts +1 -0
- package/src/interface/ITextFormatAlign.js +1 -0
- package/src/interface/IURLLoaderDataFormat.d.ts +1 -0
- package/src/interface/IURLLoaderDataFormat.js +1 -0
- package/src/interface/IURLRequestHeader.d.ts +4 -0
- package/src/interface/IURLRequestHeader.js +1 -0
- package/src/interface/IURLRequestMethod.d.ts +1 -0
- package/src/interface/IURLRequestMethod.js +1 -0
- package/src/interface/IVideoCharacter.d.ts +11 -0
- package/src/interface/IVideoCharacter.js +1 -0
- package/dist/Sound.d.ts +0 -206
- package/dist/Sound.js +0 -501
- package/dist/SoundMixer.d.ts +0 -68
- package/dist/SoundMixer.js +0 -114
- package/dist/SoundTransform.d.ts +0 -80
- package/dist/SoundTransform.js +0 -111
- package/dist/Video.d.ts +0 -328
- package/dist/Video.js +0 -897
package/src/Sound.d.ts
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import type { ISoundCharacter } from "./interface/ISoundCharacter";
|
|
2
|
+
import type { URLRequest } from "@next2d/net";
|
|
3
|
+
import { EventDispatcher } from "@next2d/events";
|
|
4
|
+
/**
|
|
5
|
+
* @description Sound クラスを使用すると、アプリケーション内のサウンドを処理することができます。
|
|
6
|
+
* Sound クラスを使用すると、Sound オブジェクトの作成や、外部 MP3 ファイルのオブジェクトへのロードと再生ができます。
|
|
7
|
+
* The Sound class lets you work with sound in an application.
|
|
8
|
+
* The Sound class lets you create a Sound object,
|
|
9
|
+
* load and play an external MP3 file into that object.
|
|
10
|
+
*
|
|
11
|
+
* @class
|
|
12
|
+
* @memberOf next2d.media
|
|
13
|
+
* @extends EventDispatcher
|
|
14
|
+
*/
|
|
15
|
+
export declare class Sound extends EventDispatcher {
|
|
16
|
+
/**
|
|
17
|
+
* @type {AudioBufferSourceNode}
|
|
18
|
+
* @default null
|
|
19
|
+
* @private
|
|
20
|
+
*/
|
|
21
|
+
private _$source;
|
|
22
|
+
/**
|
|
23
|
+
* @type {GainNode}
|
|
24
|
+
* @default null
|
|
25
|
+
* @private
|
|
26
|
+
*/
|
|
27
|
+
private _$gainNode;
|
|
28
|
+
/**
|
|
29
|
+
* @type {boolean}
|
|
30
|
+
* @default true
|
|
31
|
+
* @private
|
|
32
|
+
*/
|
|
33
|
+
private _$stopFlag;
|
|
34
|
+
/**
|
|
35
|
+
* @type {number}
|
|
36
|
+
* @default 0
|
|
37
|
+
* @private
|
|
38
|
+
*/
|
|
39
|
+
private _$currentCount;
|
|
40
|
+
/**
|
|
41
|
+
* @type {number}
|
|
42
|
+
* @default 1
|
|
43
|
+
* @private
|
|
44
|
+
*/
|
|
45
|
+
private _$volume;
|
|
46
|
+
/**
|
|
47
|
+
* @description AudioBuffer
|
|
48
|
+
* AudioBuffer
|
|
49
|
+
*
|
|
50
|
+
* @type {AudioBuffer}
|
|
51
|
+
* @default null
|
|
52
|
+
* @public
|
|
53
|
+
*/
|
|
54
|
+
audioBuffer: AudioBuffer | null;
|
|
55
|
+
/**
|
|
56
|
+
* @description ループ回数の設定
|
|
57
|
+
* Loop count setting.
|
|
58
|
+
*
|
|
59
|
+
* @type {string}
|
|
60
|
+
* @default 0
|
|
61
|
+
* @public
|
|
62
|
+
*/
|
|
63
|
+
loopCount: number;
|
|
64
|
+
/**
|
|
65
|
+
* @constructor
|
|
66
|
+
* @public
|
|
67
|
+
*/
|
|
68
|
+
constructor();
|
|
69
|
+
/**
|
|
70
|
+
* @description ボリュームです。範囲は 0(無音)~ 1(フルボリューム)です。
|
|
71
|
+
* The volume, ranging from 0 (silent) to 1 (full volume).
|
|
72
|
+
*
|
|
73
|
+
* @member {number}
|
|
74
|
+
* @default 1
|
|
75
|
+
* @public
|
|
76
|
+
*/
|
|
77
|
+
get volume(): number;
|
|
78
|
+
set volume(volume: number);
|
|
79
|
+
/**
|
|
80
|
+
* @description サウンドがループするかどうかを示します。
|
|
81
|
+
* Indicates whether the sound loops.
|
|
82
|
+
*
|
|
83
|
+
* @member {boolean}
|
|
84
|
+
* @readonly
|
|
85
|
+
* @public
|
|
86
|
+
*/
|
|
87
|
+
get canLoop(): boolean;
|
|
88
|
+
/**
|
|
89
|
+
* @description Sound クラスを複製します。
|
|
90
|
+
* Duplicate the Sound class.
|
|
91
|
+
*
|
|
92
|
+
* @return {Sound}
|
|
93
|
+
* @method
|
|
94
|
+
* @public
|
|
95
|
+
*/
|
|
96
|
+
clone(): Sound;
|
|
97
|
+
/**
|
|
98
|
+
* @description 指定した URL から外部 MP3 ファイルのロードを開始します。
|
|
99
|
+
* Initiates loading of an external MP3 file from the specified URL.
|
|
100
|
+
*
|
|
101
|
+
* @param {URLRequest} request
|
|
102
|
+
* @return {Promise}
|
|
103
|
+
* @method
|
|
104
|
+
* @public
|
|
105
|
+
*/
|
|
106
|
+
load(request: URLRequest): Promise<void>;
|
|
107
|
+
/**
|
|
108
|
+
* @description サウンドを再生します。
|
|
109
|
+
* Play a sound.
|
|
110
|
+
*
|
|
111
|
+
* @param {number} [start_time=0]
|
|
112
|
+
* @return {void}
|
|
113
|
+
* @method
|
|
114
|
+
* @public
|
|
115
|
+
*/
|
|
116
|
+
play(start_time?: number): void;
|
|
117
|
+
/**
|
|
118
|
+
* @description チャンネルで再生しているサウンドを停止します。
|
|
119
|
+
* Stops the sound playing in the channel.
|
|
120
|
+
*
|
|
121
|
+
* @return {void}
|
|
122
|
+
* @method
|
|
123
|
+
* @public
|
|
124
|
+
*/
|
|
125
|
+
stop(): void;
|
|
126
|
+
/**
|
|
127
|
+
* @description Character DataからSoundを作成
|
|
128
|
+
* Create Sound from Character Data
|
|
129
|
+
*
|
|
130
|
+
* @param {Character} character
|
|
131
|
+
* @return {Promise}
|
|
132
|
+
* @method
|
|
133
|
+
* @protected
|
|
134
|
+
*/
|
|
135
|
+
$build(character: ISoundCharacter): Promise<void>;
|
|
136
|
+
}
|
package/src/Sound.js
ADDED
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
import { SoundMixer } from "./SoundMixer";
|
|
2
|
+
import { execute as soundEndedEventService } from "./Sound/service/SoundEndedEventService";
|
|
3
|
+
import { execute as soundLoadUseCase } from "./Sound/usecase/SoundLoadUseCase";
|
|
4
|
+
import { execute as soundBuildFromCharacterUseCase } from "./Sound/usecase/SoundBuildFromCharacterUseCase";
|
|
5
|
+
import { EventDispatcher } from "@next2d/events";
|
|
6
|
+
import { $clamp, $getAudioContext, $getPlayingSounds } from "./MediaUtil";
|
|
7
|
+
/**
|
|
8
|
+
* @description Sound クラスを使用すると、アプリケーション内のサウンドを処理することができます。
|
|
9
|
+
* Sound クラスを使用すると、Sound オブジェクトの作成や、外部 MP3 ファイルのオブジェクトへのロードと再生ができます。
|
|
10
|
+
* The Sound class lets you work with sound in an application.
|
|
11
|
+
* The Sound class lets you create a Sound object,
|
|
12
|
+
* load and play an external MP3 file into that object.
|
|
13
|
+
*
|
|
14
|
+
* @class
|
|
15
|
+
* @memberOf next2d.media
|
|
16
|
+
* @extends EventDispatcher
|
|
17
|
+
*/
|
|
18
|
+
export class Sound extends EventDispatcher {
|
|
19
|
+
/**
|
|
20
|
+
* @constructor
|
|
21
|
+
* @public
|
|
22
|
+
*/
|
|
23
|
+
constructor() {
|
|
24
|
+
super();
|
|
25
|
+
/**
|
|
26
|
+
* @type {AudioBufferSourceNode}
|
|
27
|
+
* @default null
|
|
28
|
+
* @private
|
|
29
|
+
*/
|
|
30
|
+
Object.defineProperty(this, "_$source", {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
configurable: true,
|
|
33
|
+
writable: true,
|
|
34
|
+
value: void 0
|
|
35
|
+
});
|
|
36
|
+
/**
|
|
37
|
+
* @type {GainNode}
|
|
38
|
+
* @default null
|
|
39
|
+
* @private
|
|
40
|
+
*/
|
|
41
|
+
Object.defineProperty(this, "_$gainNode", {
|
|
42
|
+
enumerable: true,
|
|
43
|
+
configurable: true,
|
|
44
|
+
writable: true,
|
|
45
|
+
value: void 0
|
|
46
|
+
});
|
|
47
|
+
/**
|
|
48
|
+
* @type {boolean}
|
|
49
|
+
* @default true
|
|
50
|
+
* @private
|
|
51
|
+
*/
|
|
52
|
+
Object.defineProperty(this, "_$stopFlag", {
|
|
53
|
+
enumerable: true,
|
|
54
|
+
configurable: true,
|
|
55
|
+
writable: true,
|
|
56
|
+
value: void 0
|
|
57
|
+
});
|
|
58
|
+
/**
|
|
59
|
+
* @type {number}
|
|
60
|
+
* @default 0
|
|
61
|
+
* @private
|
|
62
|
+
*/
|
|
63
|
+
Object.defineProperty(this, "_$currentCount", {
|
|
64
|
+
enumerable: true,
|
|
65
|
+
configurable: true,
|
|
66
|
+
writable: true,
|
|
67
|
+
value: void 0
|
|
68
|
+
});
|
|
69
|
+
/**
|
|
70
|
+
* @type {number}
|
|
71
|
+
* @default 1
|
|
72
|
+
* @private
|
|
73
|
+
*/
|
|
74
|
+
Object.defineProperty(this, "_$volume", {
|
|
75
|
+
enumerable: true,
|
|
76
|
+
configurable: true,
|
|
77
|
+
writable: true,
|
|
78
|
+
value: void 0
|
|
79
|
+
});
|
|
80
|
+
/**
|
|
81
|
+
* @description AudioBuffer
|
|
82
|
+
* AudioBuffer
|
|
83
|
+
*
|
|
84
|
+
* @type {AudioBuffer}
|
|
85
|
+
* @default null
|
|
86
|
+
* @public
|
|
87
|
+
*/
|
|
88
|
+
Object.defineProperty(this, "audioBuffer", {
|
|
89
|
+
enumerable: true,
|
|
90
|
+
configurable: true,
|
|
91
|
+
writable: true,
|
|
92
|
+
value: void 0
|
|
93
|
+
});
|
|
94
|
+
/**
|
|
95
|
+
* @description ループ回数の設定
|
|
96
|
+
* Loop count setting.
|
|
97
|
+
*
|
|
98
|
+
* @type {string}
|
|
99
|
+
* @default 0
|
|
100
|
+
* @public
|
|
101
|
+
*/
|
|
102
|
+
Object.defineProperty(this, "loopCount", {
|
|
103
|
+
enumerable: true,
|
|
104
|
+
configurable: true,
|
|
105
|
+
writable: true,
|
|
106
|
+
value: void 0
|
|
107
|
+
});
|
|
108
|
+
this.loopCount = 0;
|
|
109
|
+
this.audioBuffer = null;
|
|
110
|
+
// private
|
|
111
|
+
this._$volume = 1;
|
|
112
|
+
this._$currentCount = 0;
|
|
113
|
+
this._$stopFlag = true;
|
|
114
|
+
this._$source = null;
|
|
115
|
+
this._$gainNode = null;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* @description ボリュームです。範囲は 0(無音)~ 1(フルボリューム)です。
|
|
119
|
+
* The volume, ranging from 0 (silent) to 1 (full volume).
|
|
120
|
+
*
|
|
121
|
+
* @member {number}
|
|
122
|
+
* @default 1
|
|
123
|
+
* @public
|
|
124
|
+
*/
|
|
125
|
+
get volume() {
|
|
126
|
+
return this._$volume;
|
|
127
|
+
}
|
|
128
|
+
set volume(volume) {
|
|
129
|
+
this._$volume = $clamp(Math.min(SoundMixer.volume, volume), 0, 1, 1);
|
|
130
|
+
if (this._$gainNode) {
|
|
131
|
+
this._$gainNode.gain.value = this._$volume;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* @description サウンドがループするかどうかを示します。
|
|
136
|
+
* Indicates whether the sound loops.
|
|
137
|
+
*
|
|
138
|
+
* @member {boolean}
|
|
139
|
+
* @readonly
|
|
140
|
+
* @public
|
|
141
|
+
*/
|
|
142
|
+
get canLoop() {
|
|
143
|
+
return !this._$stopFlag && this.loopCount >= this._$currentCount;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* @description Sound クラスを複製します。
|
|
147
|
+
* Duplicate the Sound class.
|
|
148
|
+
*
|
|
149
|
+
* @return {Sound}
|
|
150
|
+
* @method
|
|
151
|
+
* @public
|
|
152
|
+
*/
|
|
153
|
+
clone() {
|
|
154
|
+
const sound = new Sound();
|
|
155
|
+
sound.volume = this._$volume;
|
|
156
|
+
sound.loopCount = this.loopCount;
|
|
157
|
+
sound.audioBuffer = this.audioBuffer;
|
|
158
|
+
return sound;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* @description 指定した URL から外部 MP3 ファイルのロードを開始します。
|
|
162
|
+
* Initiates loading of an external MP3 file from the specified URL.
|
|
163
|
+
*
|
|
164
|
+
* @param {URLRequest} request
|
|
165
|
+
* @return {Promise}
|
|
166
|
+
* @method
|
|
167
|
+
* @public
|
|
168
|
+
*/
|
|
169
|
+
async load(request) {
|
|
170
|
+
await soundLoadUseCase(this, request);
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* @description サウンドを再生します。
|
|
174
|
+
* Play a sound.
|
|
175
|
+
*
|
|
176
|
+
* @param {number} [start_time=0]
|
|
177
|
+
* @return {void}
|
|
178
|
+
* @method
|
|
179
|
+
* @public
|
|
180
|
+
*/
|
|
181
|
+
play(start_time = 0) {
|
|
182
|
+
// 再生中なら終了
|
|
183
|
+
if (!this._$stopFlag) {
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
if (!this.audioBuffer) {
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
// 初期化
|
|
190
|
+
this.stop();
|
|
191
|
+
const audioContext = $getAudioContext();
|
|
192
|
+
this._$gainNode = audioContext.createGain();
|
|
193
|
+
this._$gainNode.connect(audioContext.destination);
|
|
194
|
+
this._$gainNode.gain.value = Math.min(SoundMixer.volume, this._$volume);
|
|
195
|
+
this._$source = audioContext.createBufferSource();
|
|
196
|
+
this._$source.addEventListener("ended", () => {
|
|
197
|
+
soundEndedEventService(this);
|
|
198
|
+
});
|
|
199
|
+
this._$source.buffer = this.audioBuffer;
|
|
200
|
+
this._$source.connect(this._$gainNode);
|
|
201
|
+
this._$source.start(start_time);
|
|
202
|
+
this._$stopFlag = false;
|
|
203
|
+
this._$currentCount++;
|
|
204
|
+
$getPlayingSounds().push(this);
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* @description チャンネルで再生しているサウンドを停止します。
|
|
208
|
+
* Stops the sound playing in the channel.
|
|
209
|
+
*
|
|
210
|
+
* @return {void}
|
|
211
|
+
* @method
|
|
212
|
+
* @public
|
|
213
|
+
*/
|
|
214
|
+
stop() {
|
|
215
|
+
if (this._$stopFlag) {
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
this._$stopFlag = true;
|
|
219
|
+
this._$currentCount = 0;
|
|
220
|
+
if (this._$source) {
|
|
221
|
+
this._$source.disconnect();
|
|
222
|
+
this._$source = null;
|
|
223
|
+
}
|
|
224
|
+
if (this._$gainNode) {
|
|
225
|
+
this._$gainNode.gain.value = 0;
|
|
226
|
+
this._$gainNode.disconnect();
|
|
227
|
+
this._$gainNode = null;
|
|
228
|
+
}
|
|
229
|
+
const playingSounds = $getPlayingSounds();
|
|
230
|
+
const index = playingSounds.indexOf(this);
|
|
231
|
+
if (index > -1) {
|
|
232
|
+
playingSounds.splice(index, 1);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* @description Character DataからSoundを作成
|
|
237
|
+
* Create Sound from Character Data
|
|
238
|
+
*
|
|
239
|
+
* @param {Character} character
|
|
240
|
+
* @return {Promise}
|
|
241
|
+
* @method
|
|
242
|
+
* @protected
|
|
243
|
+
*/
|
|
244
|
+
async $build(character) {
|
|
245
|
+
await soundBuildFromCharacterUseCase(this, character);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { $getPlayingSounds, $getPlayingVideos } from "../../MediaUtil";
|
|
2
|
+
/**
|
|
3
|
+
* @description 再生中のサウンドとビデオの全ての再生を停止
|
|
4
|
+
* Stops all playing sounds and videos.
|
|
5
|
+
*
|
|
6
|
+
* @return {void}
|
|
7
|
+
* @method
|
|
8
|
+
* @public
|
|
9
|
+
*/
|
|
10
|
+
export const execute = () => {
|
|
11
|
+
// sounds
|
|
12
|
+
const playingSounds = $getPlayingSounds();
|
|
13
|
+
for (let idx = 0; idx < playingSounds.length; ++idx) {
|
|
14
|
+
const sound = playingSounds[idx];
|
|
15
|
+
if (!sound) {
|
|
16
|
+
continue;
|
|
17
|
+
}
|
|
18
|
+
sound.stop();
|
|
19
|
+
}
|
|
20
|
+
// videos
|
|
21
|
+
const playingVideos = $getPlayingVideos();
|
|
22
|
+
for (let idx = 0; idx < playingVideos.length; ++idx) {
|
|
23
|
+
const video = playingVideos[idx];
|
|
24
|
+
if (!video) {
|
|
25
|
+
continue;
|
|
26
|
+
}
|
|
27
|
+
video.pause();
|
|
28
|
+
}
|
|
29
|
+
// reset
|
|
30
|
+
playingSounds.length = 0;
|
|
31
|
+
playingVideos.length = 0;
|
|
32
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { $setVolume, $getPlayingSounds, $getPlayingVideos } from "../../MediaUtil";
|
|
2
|
+
/**
|
|
3
|
+
* @description 再生中のサウンドとビデオの全ての音量を更新
|
|
4
|
+
* Updates the volume of all playing sounds and videos.
|
|
5
|
+
*
|
|
6
|
+
* @param {number} volume
|
|
7
|
+
* @method
|
|
8
|
+
* @public
|
|
9
|
+
*/
|
|
10
|
+
export const execute = (volume) => {
|
|
11
|
+
// update volume
|
|
12
|
+
$setVolume(volume);
|
|
13
|
+
const playingSounds = $getPlayingSounds();
|
|
14
|
+
for (let idx = 0; idx < playingSounds.length; ++idx) {
|
|
15
|
+
const sound = playingSounds[idx];
|
|
16
|
+
if (!sound) {
|
|
17
|
+
continue;
|
|
18
|
+
}
|
|
19
|
+
sound.volume = volume;
|
|
20
|
+
}
|
|
21
|
+
const playingVideos = $getPlayingVideos();
|
|
22
|
+
for (let idx = 0; idx < playingVideos.length; ++idx) {
|
|
23
|
+
const video = playingVideos[idx];
|
|
24
|
+
if (!video) {
|
|
25
|
+
continue;
|
|
26
|
+
}
|
|
27
|
+
video.volume = volume;
|
|
28
|
+
}
|
|
29
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SoundMixer クラスには、静的プロパティやアプリケーションのグローバルサウンドコントロールのメソッドが含まれます。
|
|
3
|
+
* SoundMixer クラスは、アプリケーションの埋め込みおよびストリーミングサウンド、及び、Video クラスの音声を制御します。
|
|
4
|
+
*
|
|
5
|
+
* @class
|
|
6
|
+
* @memberOf next2d.media
|
|
7
|
+
*/
|
|
8
|
+
export declare class SoundMixer {
|
|
9
|
+
/**
|
|
10
|
+
* @description ボリュームです。範囲は 0(無音)~ 1(フルボリューム)です。
|
|
11
|
+
* The volume, ranging from 0 (silent) to 1 (full volume).
|
|
12
|
+
*
|
|
13
|
+
* @member {number}
|
|
14
|
+
* @default 1
|
|
15
|
+
* @static
|
|
16
|
+
*/
|
|
17
|
+
static get volume(): number;
|
|
18
|
+
static set volume(volume: number);
|
|
19
|
+
/**
|
|
20
|
+
* @description 再生中のサウンドとビデオをすべて停止します。
|
|
21
|
+
* Stops all sound and video that is playing.
|
|
22
|
+
*
|
|
23
|
+
* @return {void}
|
|
24
|
+
* @method
|
|
25
|
+
* @static
|
|
26
|
+
*/
|
|
27
|
+
static stopAll(): void;
|
|
28
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { execute as soundMixerUpdateVolumeService } from "./SoundMixer/service/SoundMixerUpdateVolumeService";
|
|
2
|
+
import { execute as soundMixerStopAllService } from "./SoundMixer/service/SoundMixerStopAllService";
|
|
3
|
+
import { $getVolume } from "./MediaUtil";
|
|
4
|
+
/**
|
|
5
|
+
* SoundMixer クラスには、静的プロパティやアプリケーションのグローバルサウンドコントロールのメソッドが含まれます。
|
|
6
|
+
* SoundMixer クラスは、アプリケーションの埋め込みおよびストリーミングサウンド、及び、Video クラスの音声を制御します。
|
|
7
|
+
*
|
|
8
|
+
* @class
|
|
9
|
+
* @memberOf next2d.media
|
|
10
|
+
*/
|
|
11
|
+
export class SoundMixer {
|
|
12
|
+
/**
|
|
13
|
+
* @description ボリュームです。範囲は 0(無音)~ 1(フルボリューム)です。
|
|
14
|
+
* The volume, ranging from 0 (silent) to 1 (full volume).
|
|
15
|
+
*
|
|
16
|
+
* @member {number}
|
|
17
|
+
* @default 1
|
|
18
|
+
* @static
|
|
19
|
+
*/
|
|
20
|
+
static get volume() {
|
|
21
|
+
return $getVolume();
|
|
22
|
+
}
|
|
23
|
+
static set volume(volume) {
|
|
24
|
+
soundMixerUpdateVolumeService(volume);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* @description 再生中のサウンドとビデオをすべて停止します。
|
|
28
|
+
* Stops all sound and video that is playing.
|
|
29
|
+
*
|
|
30
|
+
* @return {void}
|
|
31
|
+
* @method
|
|
32
|
+
* @static
|
|
33
|
+
*/
|
|
34
|
+
static stopAll() {
|
|
35
|
+
soundMixerStopAllService();
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description SoundTransform クラスにはボリュームとループのプロパティが含まれます。
|
|
3
|
+
* The SoundTransform class contains properties for volume and loop.
|
|
4
|
+
*
|
|
5
|
+
* @class
|
|
6
|
+
* @memberOf next2d.media
|
|
7
|
+
*/
|
|
8
|
+
export declare class SoundTransform {
|
|
9
|
+
/**
|
|
10
|
+
* @description ボリュームです。範囲は 0(無音)~ 1(フルボリューム)です。
|
|
11
|
+
* The volume, ranging from 0 (silent) to 1 (full volume).
|
|
12
|
+
*
|
|
13
|
+
* @member {number}
|
|
14
|
+
* @default 1
|
|
15
|
+
* @public
|
|
16
|
+
*/
|
|
17
|
+
volume: number;
|
|
18
|
+
/**
|
|
19
|
+
* @description ループ回数の設定
|
|
20
|
+
* Loop count setting.
|
|
21
|
+
*
|
|
22
|
+
* @type {boolean}
|
|
23
|
+
* @default false
|
|
24
|
+
* @public
|
|
25
|
+
*/
|
|
26
|
+
loopCount: number;
|
|
27
|
+
/**
|
|
28
|
+
* @param {number} [volume=1]
|
|
29
|
+
* @param {number} [loop_count=0]
|
|
30
|
+
*
|
|
31
|
+
* @constructor
|
|
32
|
+
* @public
|
|
33
|
+
*/
|
|
34
|
+
constructor(volume?: number, loop_count?: number);
|
|
35
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description SoundTransform クラスにはボリュームとループのプロパティが含まれます。
|
|
3
|
+
* The SoundTransform class contains properties for volume and loop.
|
|
4
|
+
*
|
|
5
|
+
* @class
|
|
6
|
+
* @memberOf next2d.media
|
|
7
|
+
*/
|
|
8
|
+
export class SoundTransform {
|
|
9
|
+
/**
|
|
10
|
+
* @param {number} [volume=1]
|
|
11
|
+
* @param {number} [loop_count=0]
|
|
12
|
+
*
|
|
13
|
+
* @constructor
|
|
14
|
+
* @public
|
|
15
|
+
*/
|
|
16
|
+
constructor(volume = 1, loop_count = 0) {
|
|
17
|
+
/**
|
|
18
|
+
* @description ボリュームです。範囲は 0(無音)~ 1(フルボリューム)です。
|
|
19
|
+
* The volume, ranging from 0 (silent) to 1 (full volume).
|
|
20
|
+
*
|
|
21
|
+
* @member {number}
|
|
22
|
+
* @default 1
|
|
23
|
+
* @public
|
|
24
|
+
*/
|
|
25
|
+
Object.defineProperty(this, "volume", {
|
|
26
|
+
enumerable: true,
|
|
27
|
+
configurable: true,
|
|
28
|
+
writable: true,
|
|
29
|
+
value: void 0
|
|
30
|
+
});
|
|
31
|
+
/**
|
|
32
|
+
* @description ループ回数の設定
|
|
33
|
+
* Loop count setting.
|
|
34
|
+
*
|
|
35
|
+
* @type {boolean}
|
|
36
|
+
* @default false
|
|
37
|
+
* @public
|
|
38
|
+
*/
|
|
39
|
+
Object.defineProperty(this, "loopCount", {
|
|
40
|
+
enumerable: true,
|
|
41
|
+
configurable: true,
|
|
42
|
+
writable: true,
|
|
43
|
+
value: void 0
|
|
44
|
+
});
|
|
45
|
+
this.volume = volume;
|
|
46
|
+
this.loopCount = loop_count;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { DisplayObject } from "@next2d/display";
|
|
2
|
+
/**
|
|
3
|
+
* @description DisplayObjectの更新フラグを立てる
|
|
4
|
+
* Set the update flag of DisplayObject
|
|
5
|
+
*
|
|
6
|
+
* @param {DisplayObject} display_object
|
|
7
|
+
* @return {void}
|
|
8
|
+
* @method
|
|
9
|
+
* @protected
|
|
10
|
+
*/
|
|
11
|
+
export declare const execute: <D extends DisplayObject>(display_object: D) => void;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description DisplayObjectの更新フラグを立てる
|
|
3
|
+
* Set the update flag of DisplayObject
|
|
4
|
+
*
|
|
5
|
+
* @param {DisplayObject} display_object
|
|
6
|
+
* @return {void}
|
|
7
|
+
* @method
|
|
8
|
+
* @protected
|
|
9
|
+
*/
|
|
10
|
+
export const execute = (display_object) => {
|
|
11
|
+
display_object.changed = true;
|
|
12
|
+
const parent = display_object.parent;
|
|
13
|
+
if (parent && !parent.changed) {
|
|
14
|
+
execute(parent);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description HTMLVideoElementを作成して、各種イベントを設定する
|
|
3
|
+
* Create an HTMLVideoElement and set various events
|
|
4
|
+
*
|
|
5
|
+
* @return {HTMLVideoElement}
|
|
6
|
+
* @method
|
|
7
|
+
* @protected
|
|
8
|
+
*/
|
|
9
|
+
export const execute = () => {
|
|
10
|
+
const element = document.createElement("video");
|
|
11
|
+
element.autoplay = false;
|
|
12
|
+
element.crossOrigin = "anonymous";
|
|
13
|
+
// Required for iOS
|
|
14
|
+
element.setAttribute("playsinline", "");
|
|
15
|
+
return element;
|
|
16
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Video } from "../../Video";
|
|
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 declare const execute: (video: Video) => void;
|