lyb-pixi-js 1.1.12 → 1.1.14
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/Utils/LibPixiAudio.d.ts +4 -2
- package/Utils/LibPixiAudio.js +12 -3
- package/lyb-pixi.js +69 -69
- package/package.json +2 -1
package/Utils/LibPixiAudio.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import "@pixi/sound";
|
|
1
2
|
/** @description 音频播放器
|
|
2
3
|
* @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiAudio-音频播放器
|
|
3
4
|
*/
|
|
@@ -17,8 +18,9 @@ export declare class LibPixiAudio {
|
|
|
17
18
|
constructor();
|
|
18
19
|
/** @description 播放音效
|
|
19
20
|
* @param key 音效资源Key,内部会使用Assets.get(key)获取音频资源
|
|
21
|
+
* @param end 倒数几秒位置播放,单位秒
|
|
20
22
|
*/
|
|
21
|
-
playEffect(key: string): Promise<void>;
|
|
23
|
+
playEffect(key: string, end?: number): Promise<void>;
|
|
22
24
|
/** @description 播放音乐
|
|
23
25
|
* @param key 音效资源Key,内部会使用Assets.get(key)获取音频资源
|
|
24
26
|
*/
|
|
@@ -30,7 +32,7 @@ export declare class LibPixiAudio {
|
|
|
30
32
|
/** @description 停止播放指定音效
|
|
31
33
|
* @param key 音效资源Key,内部会使用Assets.get(key)获取音频资源进行停止
|
|
32
34
|
*/
|
|
33
|
-
stopEffect(
|
|
35
|
+
stopEffect(key: string): void;
|
|
34
36
|
/** @description 设置启用音效
|
|
35
37
|
* @param enabled 启用状态,false为禁用
|
|
36
38
|
*/
|
package/Utils/LibPixiAudio.js
CHANGED
|
@@ -7,7 +7,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
+
import gsap from "gsap";
|
|
10
11
|
import { Assets } from "pixi.js";
|
|
12
|
+
import "@pixi/sound";
|
|
11
13
|
/** @description 音频播放器
|
|
12
14
|
* @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiAudio-音频播放器
|
|
13
15
|
*/
|
|
@@ -50,8 +52,9 @@ export class LibPixiAudio {
|
|
|
50
52
|
}
|
|
51
53
|
/** @description 播放音效
|
|
52
54
|
* @param key 音效资源Key,内部会使用Assets.get(key)获取音频资源
|
|
55
|
+
* @param end 倒数几秒位置播放,单位秒
|
|
53
56
|
*/
|
|
54
|
-
playEffect(key) {
|
|
57
|
+
playEffect(key, end) {
|
|
55
58
|
return new Promise((resolve) => {
|
|
56
59
|
const id = new Date().getTime();
|
|
57
60
|
const url = Assets.get(key).url;
|
|
@@ -64,6 +67,12 @@ export class LibPixiAudio {
|
|
|
64
67
|
audio
|
|
65
68
|
.play()
|
|
66
69
|
.then(() => {
|
|
70
|
+
//倒数几秒位置播放
|
|
71
|
+
if (end) {
|
|
72
|
+
const duration = audio.duration;
|
|
73
|
+
const start = duration - end;
|
|
74
|
+
audio.currentTime = Math.max(start, 0);
|
|
75
|
+
}
|
|
67
76
|
this._playingList.push({
|
|
68
77
|
id,
|
|
69
78
|
audio,
|
|
@@ -124,8 +133,8 @@ export class LibPixiAudio {
|
|
|
124
133
|
/** @description 停止播放指定音效
|
|
125
134
|
* @param key 音效资源Key,内部会使用Assets.get(key)获取音频资源进行停止
|
|
126
135
|
*/
|
|
127
|
-
stopEffect(
|
|
128
|
-
const url = Assets.get(
|
|
136
|
+
stopEffect(key) {
|
|
137
|
+
const url = Assets.get(key).url;
|
|
129
138
|
this._playingList.forEach((item) => {
|
|
130
139
|
if (item.url === url) {
|
|
131
140
|
item.audio.pause();
|