lyb-pixi-js 1.1.12 → 1.1.13
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 +2 -1
- package/Utils/LibPixiAudio.js +9 -1
- package/lyb-pixi.js +20 -20
- package/package.json +1 -1
package/Utils/LibPixiAudio.d.ts
CHANGED
|
@@ -17,8 +17,9 @@ export declare class LibPixiAudio {
|
|
|
17
17
|
constructor();
|
|
18
18
|
/** @description 播放音效
|
|
19
19
|
* @param key 音效资源Key,内部会使用Assets.get(key)获取音频资源
|
|
20
|
+
* @param end 倒数几秒位置播放,单位秒
|
|
20
21
|
*/
|
|
21
|
-
playEffect(key: string): Promise<void>;
|
|
22
|
+
playEffect(key: string, end?: number): Promise<void>;
|
|
22
23
|
/** @description 播放音乐
|
|
23
24
|
* @param key 音效资源Key,内部会使用Assets.get(key)获取音频资源
|
|
24
25
|
*/
|
package/Utils/LibPixiAudio.js
CHANGED
|
@@ -7,6 +7,7 @@ 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";
|
|
11
12
|
/** @description 音频播放器
|
|
12
13
|
* @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiAudio-音频播放器
|
|
@@ -50,12 +51,19 @@ export class LibPixiAudio {
|
|
|
50
51
|
}
|
|
51
52
|
/** @description 播放音效
|
|
52
53
|
* @param key 音效资源Key,内部会使用Assets.get(key)获取音频资源
|
|
54
|
+
* @param end 倒数几秒位置播放,单位秒
|
|
53
55
|
*/
|
|
54
|
-
playEffect(key) {
|
|
56
|
+
playEffect(key, end) {
|
|
55
57
|
return new Promise((resolve) => {
|
|
56
58
|
const id = new Date().getTime();
|
|
57
59
|
const url = Assets.get(key).url;
|
|
58
60
|
const audio = new Audio(url);
|
|
61
|
+
//倒数几秒位置播放
|
|
62
|
+
if (end) {
|
|
63
|
+
const duration = audio.duration;
|
|
64
|
+
const start = duration - end;
|
|
65
|
+
audio.currentTime = Math.max(start, 0);
|
|
66
|
+
}
|
|
59
67
|
audio.muted = this._isBackground || !this.effectEnabled;
|
|
60
68
|
audio.addEventListener("ended", () => {
|
|
61
69
|
this._playingList = this._playingList.filter((item) => item.id !== id);
|