@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/README.md
CHANGED
package/package.json
CHANGED
|
@@ -1,26 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@next2d/media",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "Next2D Media
|
|
5
|
-
"author": "Toshiyuki Ienaga<ienaga@
|
|
3
|
+
"version": "2.0.0",
|
|
4
|
+
"description": "Next2D Media Package",
|
|
5
|
+
"author": "Toshiyuki Ienaga<ienaga@next2d.app> (https://github.com/ienaga/)",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"homepage": "https://next2d.app",
|
|
8
8
|
"bugs": "https://github.com/Next2D/Player/issues",
|
|
9
|
-
"main": "
|
|
10
|
-
"types": "
|
|
11
|
-
"
|
|
12
|
-
"dist"
|
|
13
|
-
],
|
|
9
|
+
"main": "src/index.js",
|
|
10
|
+
"types": "src/index.d.ts",
|
|
11
|
+
"type": "module",
|
|
14
12
|
"exports": {
|
|
15
13
|
".": {
|
|
16
|
-
"import":
|
|
17
|
-
|
|
18
|
-
"default": "./dist/index.js"
|
|
19
|
-
},
|
|
20
|
-
"require": {
|
|
21
|
-
"types": "./dist/index.d.ts",
|
|
22
|
-
"default": "./dist/index.js"
|
|
23
|
-
}
|
|
14
|
+
"import": "./src/index.js",
|
|
15
|
+
"require": "./src/index.js"
|
|
24
16
|
}
|
|
25
17
|
},
|
|
26
18
|
"keywords": [
|
|
@@ -31,15 +23,10 @@
|
|
|
31
23
|
"type": "git",
|
|
32
24
|
"url": "git+https://github.com/Next2D/Player.git"
|
|
33
25
|
},
|
|
34
|
-
"
|
|
35
|
-
"@next2d/events": "
|
|
36
|
-
"@next2d/net": "
|
|
37
|
-
"@next2d/display": "
|
|
38
|
-
"@next2d/
|
|
39
|
-
"@next2d/core": "1.18.12",
|
|
40
|
-
"@next2d/share": "1.18.12",
|
|
41
|
-
"@next2d/util": "1.18.12",
|
|
42
|
-
"@next2d/geom": "1.18.12",
|
|
43
|
-
"@next2d/webgl": "1.18.12"
|
|
26
|
+
"dependencies": {
|
|
27
|
+
"@next2d/events": "2.0.0",
|
|
28
|
+
"@next2d/net": "2.0.0",
|
|
29
|
+
"@next2d/display": "2.0.0",
|
|
30
|
+
"@next2d/geom": "2.0.0"
|
|
44
31
|
}
|
|
45
32
|
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import type { Sound } from "./Sound";
|
|
2
|
+
import type { Video } from "./Video";
|
|
3
|
+
import type { IAjaxOption } from "./interface/IAjaxOption";
|
|
4
|
+
/**
|
|
5
|
+
* @description ミュートになっているビデオを返却
|
|
6
|
+
* Returns the muted video.
|
|
7
|
+
*
|
|
8
|
+
* @return {Video[]}
|
|
9
|
+
* @method
|
|
10
|
+
* @public
|
|
11
|
+
*/
|
|
12
|
+
export declare const $getMutedVideos: () => Video[];
|
|
13
|
+
/**
|
|
14
|
+
* @description ミュートになっているビデオを追加
|
|
15
|
+
* Add a video that has been muted.
|
|
16
|
+
*
|
|
17
|
+
* @param {Video} video
|
|
18
|
+
* @return {void}
|
|
19
|
+
* @method
|
|
20
|
+
* @public
|
|
21
|
+
*/
|
|
22
|
+
export declare const $pushMutedVideos: (video: Video) => void;
|
|
23
|
+
/**
|
|
24
|
+
* @description AudioContext が存在するか返却
|
|
25
|
+
* Returns whether AudioContext exists.
|
|
26
|
+
*
|
|
27
|
+
* @return {boolean}
|
|
28
|
+
* @method
|
|
29
|
+
* @public
|
|
30
|
+
*/
|
|
31
|
+
export declare const $isAudioContext: () => boolean;
|
|
32
|
+
/**
|
|
33
|
+
* @description AudioContext を起動
|
|
34
|
+
* Start AudioContext.
|
|
35
|
+
*
|
|
36
|
+
* @method
|
|
37
|
+
* @private
|
|
38
|
+
*/
|
|
39
|
+
export declare const $bootAudioContext: () => void;
|
|
40
|
+
/**
|
|
41
|
+
* @description AudioContext を返却
|
|
42
|
+
* Returns AudioContext.
|
|
43
|
+
*
|
|
44
|
+
* @return {AudioContext}
|
|
45
|
+
* @method
|
|
46
|
+
* @protected
|
|
47
|
+
*/
|
|
48
|
+
export declare const $getAudioContext: () => AudioContext;
|
|
49
|
+
/**
|
|
50
|
+
* @param {object} option
|
|
51
|
+
* @return {void}
|
|
52
|
+
* @method
|
|
53
|
+
* @public
|
|
54
|
+
*/
|
|
55
|
+
export declare const $ajax: (option: IAjaxOption) => void;
|
|
56
|
+
/**
|
|
57
|
+
* @description 値が最小値と最大値の間に収まるように調整します。
|
|
58
|
+
* Adjust the value so that it falls between the minimum and maximum values.
|
|
59
|
+
*
|
|
60
|
+
* @param {number} value
|
|
61
|
+
* @param {number} min
|
|
62
|
+
* @param {number} max
|
|
63
|
+
* @param {number} [default_value=null]
|
|
64
|
+
* @return {number}
|
|
65
|
+
* @method
|
|
66
|
+
* @static
|
|
67
|
+
*/
|
|
68
|
+
export declare const $clamp: (value: number, min: number, max: number, default_value?: number | null) => number;
|
|
69
|
+
/**
|
|
70
|
+
* @description 音量を返却
|
|
71
|
+
* Returns the volume.
|
|
72
|
+
*
|
|
73
|
+
* @return {number}
|
|
74
|
+
* @method
|
|
75
|
+
* @public
|
|
76
|
+
*/
|
|
77
|
+
export declare const $getVolume: () => number;
|
|
78
|
+
/**
|
|
79
|
+
* @description 音量を設定
|
|
80
|
+
* Set the volume.
|
|
81
|
+
*
|
|
82
|
+
* @param {number} volume
|
|
83
|
+
* @method
|
|
84
|
+
* @public
|
|
85
|
+
*/
|
|
86
|
+
export declare const $setVolume: (volume: number) => void;
|
|
87
|
+
/**
|
|
88
|
+
* @description 再生中のサウンドを返却
|
|
89
|
+
* Returns the sound being played.
|
|
90
|
+
*
|
|
91
|
+
* @returns {Sound[]}
|
|
92
|
+
* @method
|
|
93
|
+
* @public
|
|
94
|
+
*/
|
|
95
|
+
export declare const $getPlayingSounds: () => Sound[];
|
|
96
|
+
/**
|
|
97
|
+
* @description 再生中のビデオを返却
|
|
98
|
+
* Returns the video being played.
|
|
99
|
+
*
|
|
100
|
+
* @returns {Video[]}
|
|
101
|
+
* @method
|
|
102
|
+
* @public
|
|
103
|
+
*/
|
|
104
|
+
export declare const $getPlayingVideos: () => Video[];
|
package/src/MediaUtil.js
ADDED
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @type {Video[]}
|
|
3
|
+
* @public
|
|
4
|
+
*/
|
|
5
|
+
const $mutedVideos = [];
|
|
6
|
+
/**
|
|
7
|
+
* @description ミュートになっているビデオを返却
|
|
8
|
+
* Returns the muted video.
|
|
9
|
+
*
|
|
10
|
+
* @return {Video[]}
|
|
11
|
+
* @method
|
|
12
|
+
* @public
|
|
13
|
+
*/
|
|
14
|
+
export const $getMutedVideos = () => {
|
|
15
|
+
return $mutedVideos;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* @description ミュートになっているビデオを追加
|
|
19
|
+
* Add a video that has been muted.
|
|
20
|
+
*
|
|
21
|
+
* @param {Video} video
|
|
22
|
+
* @return {void}
|
|
23
|
+
* @method
|
|
24
|
+
* @public
|
|
25
|
+
*/
|
|
26
|
+
export const $pushMutedVideos = (video) => {
|
|
27
|
+
$mutedVideos.push(video);
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* @type {AudioContext}
|
|
31
|
+
* @private
|
|
32
|
+
*/
|
|
33
|
+
let $audioContext = null;
|
|
34
|
+
/**
|
|
35
|
+
* @description AudioContext が存在するか返却
|
|
36
|
+
* Returns whether AudioContext exists.
|
|
37
|
+
*
|
|
38
|
+
* @return {boolean}
|
|
39
|
+
* @method
|
|
40
|
+
* @public
|
|
41
|
+
*/
|
|
42
|
+
export const $isAudioContext = () => {
|
|
43
|
+
return !!$audioContext;
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* @description AudioContext を起動
|
|
47
|
+
* Start AudioContext.
|
|
48
|
+
*
|
|
49
|
+
* @method
|
|
50
|
+
* @private
|
|
51
|
+
*/
|
|
52
|
+
export const $bootAudioContext = () => {
|
|
53
|
+
if (!$audioContext) {
|
|
54
|
+
$audioContext = new AudioContext();
|
|
55
|
+
}
|
|
56
|
+
$audioContext.resume();
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* @description AudioContext を返却
|
|
60
|
+
* Returns AudioContext.
|
|
61
|
+
*
|
|
62
|
+
* @return {AudioContext}
|
|
63
|
+
* @method
|
|
64
|
+
* @protected
|
|
65
|
+
*/
|
|
66
|
+
export const $getAudioContext = () => {
|
|
67
|
+
if (!$audioContext) {
|
|
68
|
+
$audioContext = new AudioContext();
|
|
69
|
+
}
|
|
70
|
+
return $audioContext;
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* @param {object} option
|
|
74
|
+
* @return {void}
|
|
75
|
+
* @method
|
|
76
|
+
* @public
|
|
77
|
+
*/
|
|
78
|
+
export const $ajax = (option) => {
|
|
79
|
+
// get or post
|
|
80
|
+
let postData = null;
|
|
81
|
+
switch (option.method.toUpperCase()) {
|
|
82
|
+
case "GET":
|
|
83
|
+
if (option.data) {
|
|
84
|
+
const urls = option.url.split("?");
|
|
85
|
+
urls[1] = urls.length === 1
|
|
86
|
+
? option.data.toString()
|
|
87
|
+
: `${urls[1]}&${option.data.toString()}`;
|
|
88
|
+
option.url = urls.join("?");
|
|
89
|
+
}
|
|
90
|
+
break;
|
|
91
|
+
case "PUT":
|
|
92
|
+
case "POST":
|
|
93
|
+
if (option.data) {
|
|
94
|
+
postData = option.data.toString();
|
|
95
|
+
}
|
|
96
|
+
break;
|
|
97
|
+
default:
|
|
98
|
+
break;
|
|
99
|
+
}
|
|
100
|
+
// start
|
|
101
|
+
const xmlHttpRequest = new XMLHttpRequest();
|
|
102
|
+
// init
|
|
103
|
+
xmlHttpRequest.open(option.method, option.url, true);
|
|
104
|
+
// set mimeType
|
|
105
|
+
xmlHttpRequest.responseType = option.format;
|
|
106
|
+
// use cookie
|
|
107
|
+
xmlHttpRequest.withCredentials = option.withCredentials;
|
|
108
|
+
// add event
|
|
109
|
+
if (option.event) {
|
|
110
|
+
const keys = Object.keys(option.event);
|
|
111
|
+
for (let idx = 0; idx < keys.length; ++idx) {
|
|
112
|
+
const name = keys[idx];
|
|
113
|
+
// @ts-ignore
|
|
114
|
+
xmlHttpRequest.addEventListener(name, option.event[name]);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
// set request header
|
|
118
|
+
for (let idx = 0; idx < option.headers.length; ++idx) {
|
|
119
|
+
const header = option.headers[idx];
|
|
120
|
+
if (!header) {
|
|
121
|
+
continue;
|
|
122
|
+
}
|
|
123
|
+
xmlHttpRequest.setRequestHeader(header.name, header.value);
|
|
124
|
+
}
|
|
125
|
+
xmlHttpRequest.send(postData);
|
|
126
|
+
};
|
|
127
|
+
/**
|
|
128
|
+
* @description 値が最小値と最大値の間に収まるように調整します。
|
|
129
|
+
* Adjust the value so that it falls between the minimum and maximum values.
|
|
130
|
+
*
|
|
131
|
+
* @param {number} value
|
|
132
|
+
* @param {number} min
|
|
133
|
+
* @param {number} max
|
|
134
|
+
* @param {number} [default_value=null]
|
|
135
|
+
* @return {number}
|
|
136
|
+
* @method
|
|
137
|
+
* @static
|
|
138
|
+
*/
|
|
139
|
+
export const $clamp = (value, min, max, default_value = null) => {
|
|
140
|
+
const number = +value;
|
|
141
|
+
return isNaN(number) && default_value !== null
|
|
142
|
+
? default_value
|
|
143
|
+
: Math.min(Math.max(min, isNaN(number) ? 0 : number), max);
|
|
144
|
+
};
|
|
145
|
+
/**
|
|
146
|
+
* @type {number}
|
|
147
|
+
* @private
|
|
148
|
+
*/
|
|
149
|
+
let $volume = 1;
|
|
150
|
+
/**
|
|
151
|
+
* @description 音量を返却
|
|
152
|
+
* Returns the volume.
|
|
153
|
+
*
|
|
154
|
+
* @return {number}
|
|
155
|
+
* @method
|
|
156
|
+
* @public
|
|
157
|
+
*/
|
|
158
|
+
export const $getVolume = () => {
|
|
159
|
+
return $volume;
|
|
160
|
+
};
|
|
161
|
+
/**
|
|
162
|
+
* @description 音量を設定
|
|
163
|
+
* Set the volume.
|
|
164
|
+
*
|
|
165
|
+
* @param {number} volume
|
|
166
|
+
* @method
|
|
167
|
+
* @public
|
|
168
|
+
*/
|
|
169
|
+
export const $setVolume = (volume) => {
|
|
170
|
+
$volume = $clamp(volume, 0, 1, 1);
|
|
171
|
+
};
|
|
172
|
+
/**
|
|
173
|
+
* @type {Sound[]}
|
|
174
|
+
* @private
|
|
175
|
+
*/
|
|
176
|
+
const $playingSounds = [];
|
|
177
|
+
/**
|
|
178
|
+
* @description 再生中のサウンドを返却
|
|
179
|
+
* Returns the sound being played.
|
|
180
|
+
*
|
|
181
|
+
* @returns {Sound[]}
|
|
182
|
+
* @method
|
|
183
|
+
* @public
|
|
184
|
+
*/
|
|
185
|
+
export const $getPlayingSounds = () => {
|
|
186
|
+
return $playingSounds;
|
|
187
|
+
};
|
|
188
|
+
/**
|
|
189
|
+
* @type {Video[]}
|
|
190
|
+
* @private
|
|
191
|
+
*/
|
|
192
|
+
const $playingVideos = [];
|
|
193
|
+
/**
|
|
194
|
+
* @description 再生中のビデオを返却
|
|
195
|
+
* Returns the video being played.
|
|
196
|
+
*
|
|
197
|
+
* @returns {Video[]}
|
|
198
|
+
* @method
|
|
199
|
+
* @public
|
|
200
|
+
*/
|
|
201
|
+
export const $getPlayingVideos = () => {
|
|
202
|
+
return $playingVideos;
|
|
203
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description ArrayBufferをデコードしてAudioBufferを返却
|
|
3
|
+
* Decode Uint8Array and return AudioBuffer.
|
|
4
|
+
*
|
|
5
|
+
* @param {ArrayBuffer} array_buffer
|
|
6
|
+
* @return {AudioBuffer | void}
|
|
7
|
+
* @method
|
|
8
|
+
* @public
|
|
9
|
+
*/
|
|
10
|
+
export declare const execute: (array_buffer: ArrayBuffer) => Promise<AudioBuffer | void>;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { $getAudioContext } from "../../MediaUtil";
|
|
2
|
+
/**
|
|
3
|
+
* @description ArrayBufferをデコードしてAudioBufferを返却
|
|
4
|
+
* Decode Uint8Array and return AudioBuffer.
|
|
5
|
+
*
|
|
6
|
+
* @param {ArrayBuffer} array_buffer
|
|
7
|
+
* @return {AudioBuffer | void}
|
|
8
|
+
* @method
|
|
9
|
+
* @public
|
|
10
|
+
*/
|
|
11
|
+
export const execute = async (array_buffer) => {
|
|
12
|
+
if (!array_buffer.byteLength) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
try {
|
|
16
|
+
return await $getAudioContext().decodeAudioData(array_buffer);
|
|
17
|
+
}
|
|
18
|
+
catch (_) {
|
|
19
|
+
const buffer = new Uint8Array(array_buffer);
|
|
20
|
+
let idx = 0;
|
|
21
|
+
for (; idx > buffer.byteLength;) {
|
|
22
|
+
idx = buffer.indexOf(0xff, idx);
|
|
23
|
+
if (idx === -1 || (buffer[idx + 1] & 0xe0) === 0xe0) {
|
|
24
|
+
break;
|
|
25
|
+
}
|
|
26
|
+
++idx;
|
|
27
|
+
}
|
|
28
|
+
return await execute(buffer.subarray(idx).buffer);
|
|
29
|
+
}
|
|
30
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Sound } from "../../Sound";
|
|
2
|
+
/**
|
|
3
|
+
* @description サウンドデータの再生終了時のイベント実行関数
|
|
4
|
+
* Event execution function when sound data playback ends
|
|
5
|
+
*
|
|
6
|
+
* @param {Sound} sound
|
|
7
|
+
* @return {void}
|
|
8
|
+
* @method
|
|
9
|
+
* @public
|
|
10
|
+
*/
|
|
11
|
+
export declare const execute: (sound: Sound) => void;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Event } from "@next2d/events";
|
|
2
|
+
/**
|
|
3
|
+
* @description サウンドデータの再生終了時のイベント実行関数
|
|
4
|
+
* Event execution function when sound data playback ends
|
|
5
|
+
*
|
|
6
|
+
* @param {Sound} sound
|
|
7
|
+
* @return {void}
|
|
8
|
+
* @method
|
|
9
|
+
* @public
|
|
10
|
+
*/
|
|
11
|
+
export const execute = (sound) => {
|
|
12
|
+
if (sound.canLoop) {
|
|
13
|
+
sound.play();
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
sound.stop();
|
|
17
|
+
if (sound.willTrigger(Event.COMPLETE)) {
|
|
18
|
+
sound.dispatchEvent(new Event(Event.COMPLETE));
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Sound } from "../../Sound";
|
|
2
|
+
/**
|
|
3
|
+
* @description サウンドの読み込みが開始イベントの実行関数
|
|
4
|
+
* Execution function of the sound loading start event
|
|
5
|
+
*
|
|
6
|
+
* @param {Sound} sound
|
|
7
|
+
* @param {ProgressEvent} event
|
|
8
|
+
* @return {void}
|
|
9
|
+
* @method
|
|
10
|
+
* @public
|
|
11
|
+
*/
|
|
12
|
+
export declare const execute: (sound: Sound, event: ProgressEvent) => void;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Event, ProgressEvent as Next2DProgressEvent } from "@next2d/events";
|
|
2
|
+
/**
|
|
3
|
+
* @description サウンドの読み込みが開始イベントの実行関数
|
|
4
|
+
* Execution function of the sound loading start event
|
|
5
|
+
*
|
|
6
|
+
* @param {Sound} sound
|
|
7
|
+
* @param {ProgressEvent} event
|
|
8
|
+
* @return {void}
|
|
9
|
+
* @method
|
|
10
|
+
* @public
|
|
11
|
+
*/
|
|
12
|
+
export const execute = (sound, event) => {
|
|
13
|
+
if (sound.willTrigger(Event.OPEN)) {
|
|
14
|
+
sound.dispatchEvent(new Event(Event.OPEN));
|
|
15
|
+
}
|
|
16
|
+
if (sound.willTrigger(Next2DProgressEvent.PROGRESS)) {
|
|
17
|
+
sound.dispatchEvent(new Next2DProgressEvent(Next2DProgressEvent.PROGRESS, false, event.loaded, event.total));
|
|
18
|
+
}
|
|
19
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Sound } from "../../Sound";
|
|
2
|
+
/**
|
|
3
|
+
* @description サウンドデータのローディング中のイベント実行関数
|
|
4
|
+
* Event execution function during sound data loading
|
|
5
|
+
*
|
|
6
|
+
* @param {Sound} sound
|
|
7
|
+
* @param {ProgressEvent} event
|
|
8
|
+
* @return {void}
|
|
9
|
+
* @method
|
|
10
|
+
* @public
|
|
11
|
+
*/
|
|
12
|
+
export declare const execute: (sound: Sound, event: ProgressEvent) => void;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ProgressEvent as Next2DProgressEvent } from "@next2d/events";
|
|
2
|
+
/**
|
|
3
|
+
* @description サウンドデータのローディング中のイベント実行関数
|
|
4
|
+
* Event execution function during sound data loading
|
|
5
|
+
*
|
|
6
|
+
* @param {Sound} sound
|
|
7
|
+
* @param {ProgressEvent} event
|
|
8
|
+
* @return {void}
|
|
9
|
+
* @method
|
|
10
|
+
* @public
|
|
11
|
+
*/
|
|
12
|
+
export const execute = (sound, event) => {
|
|
13
|
+
if (sound.willTrigger(Next2DProgressEvent.PROGRESS)) {
|
|
14
|
+
sound.dispatchEvent(new Next2DProgressEvent(Next2DProgressEvent.PROGRESS, false, event.loaded, event.total));
|
|
15
|
+
}
|
|
16
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ISoundCharacter } from "../../interface/ISoundCharacter";
|
|
2
|
+
import type { Sound } from "../../Sound";
|
|
3
|
+
/**
|
|
4
|
+
* @description キャラクターからSoundを構築
|
|
5
|
+
* Build Sound from character
|
|
6
|
+
*
|
|
7
|
+
* @param {Sound} sound
|
|
8
|
+
* @param {ISoundCharacter} character
|
|
9
|
+
* @return {Promise<void>}
|
|
10
|
+
* @method
|
|
11
|
+
* @protected
|
|
12
|
+
*/
|
|
13
|
+
export declare const execute: (sound: Sound, character: ISoundCharacter) => Promise<void>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { execute as soundDecodeService } from "../service/SoundDecodeService";
|
|
2
|
+
/**
|
|
3
|
+
* @description キャラクターからSoundを構築
|
|
4
|
+
* Build Sound from character
|
|
5
|
+
*
|
|
6
|
+
* @param {Sound} sound
|
|
7
|
+
* @param {ISoundCharacter} character
|
|
8
|
+
* @return {Promise<void>}
|
|
9
|
+
* @method
|
|
10
|
+
* @protected
|
|
11
|
+
*/
|
|
12
|
+
export const execute = async (sound, character) => {
|
|
13
|
+
// load AudioBuffer
|
|
14
|
+
if (!character.audioBuffer) {
|
|
15
|
+
const uint8Array = new Uint8Array(character.buffer);
|
|
16
|
+
const audioBuffer = await soundDecodeService(uint8Array.buffer);
|
|
17
|
+
if (!audioBuffer) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
character.audioBuffer = audioBuffer;
|
|
21
|
+
}
|
|
22
|
+
sound.audioBuffer = character.audioBuffer;
|
|
23
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Sound } from "../../Sound";
|
|
2
|
+
/**
|
|
3
|
+
* @description サウンドデータのローディング完了イベントの実行関数
|
|
4
|
+
* Execution function for sound data loading completion event
|
|
5
|
+
*
|
|
6
|
+
* @param {Sound} sound
|
|
7
|
+
* @param {ProgressEvent} event
|
|
8
|
+
* @return {Promise}
|
|
9
|
+
* @method
|
|
10
|
+
* @public
|
|
11
|
+
*/
|
|
12
|
+
export declare const execute: (sound: Sound, event: ProgressEvent) => Promise<AudioBuffer | void>;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { execute as soundDecodeService } from "../service/SoundDecodeService";
|
|
2
|
+
import { Event, ProgressEvent as Next2DProgressEvent, IOErrorEvent } from "@next2d/events";
|
|
3
|
+
/**
|
|
4
|
+
* @description サウンドデータのローディング完了イベントの実行関数
|
|
5
|
+
* Execution function for sound data loading completion event
|
|
6
|
+
*
|
|
7
|
+
* @param {Sound} sound
|
|
8
|
+
* @param {ProgressEvent} event
|
|
9
|
+
* @return {Promise}
|
|
10
|
+
* @method
|
|
11
|
+
* @public
|
|
12
|
+
*/
|
|
13
|
+
export const execute = async (sound, event) => {
|
|
14
|
+
const target = event.target;
|
|
15
|
+
if (!target) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
if (sound.willTrigger(Next2DProgressEvent.PROGRESS)) {
|
|
19
|
+
sound.dispatchEvent(new Next2DProgressEvent(Next2DProgressEvent.PROGRESS, false, event.loaded, event.total));
|
|
20
|
+
}
|
|
21
|
+
if (199 < target.status && 400 > target.status) {
|
|
22
|
+
const audioBuffer = await soundDecodeService(target.response);
|
|
23
|
+
if (audioBuffer) {
|
|
24
|
+
sound.audioBuffer = audioBuffer;
|
|
25
|
+
if (sound.willTrigger(Event.COMPLETE)) {
|
|
26
|
+
sound.dispatchEvent(new Event(Event.COMPLETE));
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
if (sound.willTrigger(IOErrorEvent.IO_ERROR)) {
|
|
32
|
+
sound.dispatchEvent(new IOErrorEvent(IOErrorEvent.IO_ERROR, false, target.statusText));
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { URLRequest } from "@next2d/net";
|
|
2
|
+
import type { Sound } from "../../Sound";
|
|
3
|
+
/**
|
|
4
|
+
* @description 外部サウンドの読み込みを実行
|
|
5
|
+
* Execute sound loading
|
|
6
|
+
*
|
|
7
|
+
* @param {Sound} sound
|
|
8
|
+
* @param {URLRequest} request
|
|
9
|
+
* @return {Promise}
|
|
10
|
+
* @method
|
|
11
|
+
* @protected
|
|
12
|
+
*/
|
|
13
|
+
export declare const execute: (sound: Sound, request: URLRequest) => Promise<void>;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { execute as soundLoadStartEventService } from "../service/SoundLoadStartEventService";
|
|
2
|
+
import { execute as soundProgressEventService } from "../service/SoundProgressEventService";
|
|
3
|
+
import { execute as soundLoadEndEventUseCase } from "../usecase/SoundLoadEndEventUseCase";
|
|
4
|
+
import { $ajax } from "../../MediaUtil";
|
|
5
|
+
/**
|
|
6
|
+
* @description 外部サウンドの読み込みを実行
|
|
7
|
+
* Execute sound loading
|
|
8
|
+
*
|
|
9
|
+
* @param {Sound} sound
|
|
10
|
+
* @param {URLRequest} request
|
|
11
|
+
* @return {Promise}
|
|
12
|
+
* @method
|
|
13
|
+
* @protected
|
|
14
|
+
*/
|
|
15
|
+
export const execute = async (sound, request) => {
|
|
16
|
+
await new Promise((resolve) => {
|
|
17
|
+
$ajax({
|
|
18
|
+
"format": "arraybuffer",
|
|
19
|
+
"url": request.url,
|
|
20
|
+
"method": request.method,
|
|
21
|
+
"data": request.data,
|
|
22
|
+
"headers": request.headers,
|
|
23
|
+
"withCredentials": request.withCredentials,
|
|
24
|
+
"event": {
|
|
25
|
+
"loadstart": (event) => {
|
|
26
|
+
soundLoadStartEventService(sound, event);
|
|
27
|
+
},
|
|
28
|
+
"progress": (event) => {
|
|
29
|
+
soundProgressEventService(sound, event);
|
|
30
|
+
},
|
|
31
|
+
"loadend": async (event) => {
|
|
32
|
+
await soundLoadEndEventUseCase(sound, event);
|
|
33
|
+
resolve();
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
};
|