lyb-pixi-js 1.1.13 → 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.
@@ -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
  */
@@ -31,7 +32,7 @@ export declare class LibPixiAudio {
31
32
  /** @description 停止播放指定音效
32
33
  * @param key 音效资源Key,内部会使用Assets.get(key)获取音频资源进行停止
33
34
  */
34
- stopEffect(link: string): void;
35
+ stopEffect(key: string): void;
35
36
  /** @description 设置启用音效
36
37
  * @param enabled 启用状态,false为禁用
37
38
  */
@@ -9,6 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  };
10
10
  import gsap from "gsap";
11
11
  import { Assets } from "pixi.js";
12
+ import "@pixi/sound";
12
13
  /** @description 音频播放器
13
14
  * @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiAudio-音频播放器
14
15
  */
@@ -58,12 +59,6 @@ export class LibPixiAudio {
58
59
  const id = new Date().getTime();
59
60
  const url = Assets.get(key).url;
60
61
  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
- }
67
62
  audio.muted = this._isBackground || !this.effectEnabled;
68
63
  audio.addEventListener("ended", () => {
69
64
  this._playingList = this._playingList.filter((item) => item.id !== id);
@@ -72,6 +67,12 @@ export class LibPixiAudio {
72
67
  audio
73
68
  .play()
74
69
  .then(() => {
70
+ //倒数几秒位置播放
71
+ if (end) {
72
+ const duration = audio.duration;
73
+ const start = duration - end;
74
+ audio.currentTime = Math.max(start, 0);
75
+ }
75
76
  this._playingList.push({
76
77
  id,
77
78
  audio,
@@ -132,8 +133,8 @@ export class LibPixiAudio {
132
133
  /** @description 停止播放指定音效
133
134
  * @param key 音效资源Key,内部会使用Assets.get(key)获取音频资源进行停止
134
135
  */
135
- stopEffect(link) {
136
- const url = Assets.get(link).url;
136
+ stopEffect(key) {
137
+ const url = Assets.get(key).url;
137
138
  this._playingList.forEach((item) => {
138
139
  if (item.url === url) {
139
140
  item.audio.pause();