@galacean/effects-plugin-multimedia 2.1.0-alpha.10

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/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ MIT LICENSE
2
+
3
+ Copyright (c) 2019-present Ant Group Co., Ltd. https://www.antgroup.com/
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,25 @@
1
+ # Galacean Effects Multimedia Plugin
2
+
3
+ ## Usage
4
+
5
+ ### Simple Import
6
+
7
+ ``` ts
8
+ import { Player } from '@galacean/effects';
9
+ import '@galacean/effects-plugin-multimedia';
10
+ ```
11
+
12
+ ## Development
13
+
14
+ ### Getting Started
15
+
16
+ ``` bash
17
+ # demo
18
+ pnpm --filter @galacean/effects-plugin-multimedia dev
19
+ ```
20
+
21
+ > [Open in browser](http://localhost:8081/demo/)
22
+
23
+ ## Frame Comparison Testing
24
+
25
+ > [Open in browser](http://localhost:8081/test/)
@@ -0,0 +1,40 @@
1
+ import { RendererComponent, spec } from '@galacean/effects';
2
+ import { AudioPlayer } from './audio-player';
3
+ export declare class AudioComponent extends RendererComponent {
4
+ audioPlayer: AudioPlayer;
5
+ private isVideoPlay;
6
+ private threshold;
7
+ onUpdate(dt: number): void;
8
+ fromData(data: spec.AudioComponentData): void;
9
+ /**
10
+ * 设置音频资源
11
+ * @param audio - 音频资源
12
+ */
13
+ setAudioSource(audio: HTMLAudioElement | AudioBuffer): void;
14
+ /**
15
+ * 设置音量
16
+ * @param volume - 音量
17
+ */
18
+ setVolume(volume: number): void;
19
+ /**
20
+ * 获取当前音频的播放时刻
21
+ */
22
+ getCurrentTime(): number;
23
+ /**
24
+ * 设置是否静音
25
+ * @param muted - 是否静音
26
+ */
27
+ setMuted(muted: boolean): void;
28
+ /**
29
+ * 设置是否循环播放
30
+ * @param loop - 是否循环播放
31
+ */
32
+ setLoop(loop: boolean): void;
33
+ /**
34
+ * 设置播放速率
35
+ * @param rate - 播放速率
36
+ */
37
+ setPlaybackRate(rate: number): void;
38
+ onDisable(): void;
39
+ dispose(): void;
40
+ }
@@ -0,0 +1,11 @@
1
+ import type { SceneLoadOptions } from '@galacean/effects';
2
+ import { spec, AbstractPlugin } from '@galacean/effects';
3
+ /**
4
+ * 音频加载插件
5
+ */
6
+ export declare class AudioLoader extends AbstractPlugin {
7
+ static processAssets(json: spec.JSONScene, options?: SceneLoadOptions): Promise<{
8
+ assets: spec.AssetBase[];
9
+ loadedAssets: (HTMLAudioElement | AudioBuffer)[];
10
+ }>;
11
+ }
@@ -0,0 +1,38 @@
1
+ import type { Engine } from '@galacean/effects';
2
+ import { spec } from '@galacean/effects';
3
+ interface AudioSourceInfo {
4
+ source?: AudioBufferSourceNode;
5
+ audioContext?: AudioContext;
6
+ gainNode?: GainNode;
7
+ }
8
+ export interface AudioPlayerOptions {
9
+ endBehavior: spec.EndBehavior;
10
+ duration: number;
11
+ }
12
+ export declare class AudioPlayer {
13
+ private engine;
14
+ audio?: HTMLAudioElement;
15
+ audioSourceInfo: AudioSourceInfo;
16
+ private isSupportAudioContext;
17
+ private options;
18
+ private destroyed;
19
+ private started;
20
+ private initialized;
21
+ private currentVolume;
22
+ constructor(audio: AudioBuffer | HTMLAudioElement, engine: Engine);
23
+ /**
24
+ * 设置音频资源
25
+ * @param audio - 音频资源
26
+ */
27
+ setAudioSource(audio: AudioBuffer | HTMLAudioElement): void;
28
+ getCurrentTime(): number;
29
+ play(): void;
30
+ pause(): void;
31
+ setVolume(volume: number): void;
32
+ setPlaybackRate(rate: number): void;
33
+ setLoop(loop: boolean): void;
34
+ setOptions(options: AudioPlayerOptions): void;
35
+ setMuted(muted: boolean): void;
36
+ dispose(): void;
37
+ }
38
+ export {};
@@ -0,0 +1,4 @@
1
+ export declare const multimediaErrorMessageMap: Record<number, string>;
2
+ export declare const multimediaErrorDisplayMessageMap: {
3
+ 2000: string;
4
+ };
@@ -0,0 +1,9 @@
1
+ export * from './video/video-component';
2
+ export * from './audio/audio-component';
3
+ export * from './audio/audio-player';
4
+ export * from './constants';
5
+ export * from './utils';
6
+ /**
7
+ * 插件版本号
8
+ */
9
+ export declare const version: string;