@audiowalk/sdk 2.0.0-rc → 2.0.0-rc.2
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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"objects.d.ts","sourceRoot":"","sources":["../../src/helpers/objects.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,CAAC,IAAI,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC"}
|
|
1
|
+
{"version":3,"file":"objects.d.ts","sourceRoot":"","sources":["../../src/helpers/objects.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,CAAC,IAAI,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AAE/E,MAAM,MAAM,UAAU,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,CAAC,IAAI,CAAC,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC"}
|
|
@@ -35,13 +35,17 @@ export declare class PlayerController {
|
|
|
35
35
|
private fadeCancelEvent;
|
|
36
36
|
constructor(trackId: string, trackUrl: string, options?: PlayerControllerParams);
|
|
37
37
|
open(file: string): Promise<void>;
|
|
38
|
-
destroy(
|
|
38
|
+
destroy(params?: {
|
|
39
|
+
now?: boolean;
|
|
40
|
+
}): Promise<void>;
|
|
39
41
|
private destroyNow;
|
|
40
42
|
preload(): Promise<void>;
|
|
41
43
|
play(params?: {
|
|
42
44
|
fade?: boolean;
|
|
45
|
+
}): Promise<this | undefined>;
|
|
46
|
+
pause(params?: {
|
|
47
|
+
fade?: boolean;
|
|
43
48
|
}): Promise<void>;
|
|
44
|
-
pause(): Promise<void>;
|
|
45
49
|
stop(params?: {
|
|
46
50
|
fade?: boolean;
|
|
47
51
|
}): Promise<void>;
|
|
@@ -49,7 +53,9 @@ export declare class PlayerController {
|
|
|
49
53
|
setVolume(volume: number, params?: {
|
|
50
54
|
fade?: boolean;
|
|
51
55
|
}): Promise<void>;
|
|
52
|
-
fadeToVolume
|
|
56
|
+
private fadeToVolume;
|
|
57
|
+
fadeOut(): Promise<void>;
|
|
58
|
+
fadeIn(): Promise<void>;
|
|
53
59
|
back(seconds?: number): void;
|
|
54
60
|
forward(seconds?: number): void;
|
|
55
61
|
private savePosition;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"player.controller.d.ts","sourceRoot":"","sources":["../../src/player/player.controller.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAwC,OAAO,EAAmB,MAAM,MAAM,CAAC;AACvG,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAG/C,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,YAAY,CAAC,EAAE,gBAAgB,CAAC;IAChC,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,MAAM,sBAAsB,GAAG,SAAS,CAAC,uBAAuB,EAAE,eAAe,CAAC,CAAC;AAEzF,oBAAY,YAAY;IACtB,SAAS,YAAY;IACrB,QAAQ,WAAW;IACnB,OAAO,UAAU;CAClB;AAED,qBAAa,gBAAgB;IA+Bf,OAAO,CAAC,OAAO;IA9B3B,SAAgB,MAAM,gBAAuB;IAC7C,SAAgB,OAAO,gBAAuB;IAC9C,SAAgB,MAAM,gBAAuB;IAE7C,SAAgB,WAAW,0BAAkC;IAC7D,SAAgB,SAAS,iCAA4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95
95
|
this.playerElement.volume = this.volume;
|
|
96
96
|
}
|
|
97
|
-
async destroy(
|
|
98
|
-
this.log("Called destroy"
|
|
97
|
+
async destroy(params = { now: false }) {
|
|
98
|
+
this.log("Called destroy", params);
|
|
99
99
|
this.destroyed = true;
|
|
100
100
|
if (this.status.value !== PlayerStatus.ended) {
|
|
101
101
|
await this.stop();
|
|
102
102
|
return this.destroyNow();
|
|
103
103
|
}
|
|
104
104
|
// if crossfade is enabled, we might be ending crossfade just now, so wait for the crossfade to finish
|
|
105
|
-
if (this.options.crossfade && now !== true) {
|
|
105
|
+
if (this.options.crossfade && params.now !== true) {
|
|
106
106
|
setTimeout(() => this.destroyNow(), this.options.crossfadeTime);
|
|
107
107
|
}
|
|
108
108
|
else {
|
|
@@ -119,7 +119,7 @@ export class PlayerController {
|
|
|
119
119
|
async preload() {
|
|
120
120
|
this.log("Called preload");
|
|
121
121
|
this.playerElement.volume = 0.01;
|
|
122
|
-
this.playerElement.play().catch(() => { });
|
|
122
|
+
await this.playerElement.play().catch(() => { });
|
|
123
123
|
this.playerElement.pause();
|
|
124
124
|
this.playerElement.volume = this.volume;
|
|
125
125
|
this.log("Preloaded");
|
|
@@ -129,34 +129,39 @@ export class PlayerController {
|
|
|
129
129
|
throw new Error("No file opened");
|
|
130
130
|
if (this.status.value === PlayerStatus.playing)
|
|
131
131
|
return;
|
|
132
|
-
this.log("Called play"
|
|
132
|
+
this.log("Called play", params);
|
|
133
133
|
await this.playerElement?.play();
|
|
134
134
|
if (params.fade) {
|
|
135
|
-
this.
|
|
136
|
-
await this.fadeToVolume(this.volume);
|
|
135
|
+
await this.fadeIn();
|
|
137
136
|
}
|
|
138
137
|
else {
|
|
139
138
|
this.playerElement.volume = this.volume;
|
|
140
139
|
}
|
|
140
|
+
return this;
|
|
141
141
|
}
|
|
142
|
-
async pause() {
|
|
142
|
+
async pause(params = { fade: this.options.crossfade }) {
|
|
143
143
|
if (!this.playerElement.src)
|
|
144
144
|
throw new Error("No file opened");
|
|
145
145
|
if (this.status.value === PlayerStatus.ended)
|
|
146
146
|
return;
|
|
147
|
-
this.log("Called pause");
|
|
147
|
+
this.log("Called pause", params);
|
|
148
|
+
if (params.fade) {
|
|
149
|
+
await this.fadeOut();
|
|
150
|
+
}
|
|
148
151
|
this.playerElement?.pause();
|
|
149
152
|
}
|
|
150
153
|
async stop(params = { fade: this.options.crossfade }) {
|
|
151
|
-
this.log("Called stop", params
|
|
154
|
+
this.log("Called stop", params);
|
|
152
155
|
if (!this.destroyed && this.status.value !== PlayerStatus.ended) {
|
|
153
156
|
this.status.next(PlayerStatus.ended);
|
|
154
157
|
this.onStop.next();
|
|
155
158
|
}
|
|
156
159
|
if (params.fade) {
|
|
157
|
-
await this.
|
|
160
|
+
await this.fadeOut();
|
|
161
|
+
}
|
|
162
|
+
else {
|
|
163
|
+
this.playerElement.pause();
|
|
158
164
|
}
|
|
159
|
-
this.playerElement.pause();
|
|
160
165
|
this.playerElement.currentTime = 0;
|
|
161
166
|
}
|
|
162
167
|
seekTo(seconds) {
|
|
@@ -164,7 +169,7 @@ export class PlayerController {
|
|
|
164
169
|
throw new Error("No file opened");
|
|
165
170
|
if (this.status.value === PlayerStatus.ended)
|
|
166
171
|
return;
|
|
167
|
-
this.log("Called seekTo");
|
|
172
|
+
this.log("Called seekTo", seconds);
|
|
168
173
|
this.playerElement.currentTime = seconds;
|
|
169
174
|
}
|
|
170
175
|
async setVolume(volume, params = {}) {
|
|
@@ -177,13 +182,12 @@ export class PlayerController {
|
|
|
177
182
|
this.playerElement.volume = Math.max(Math.min(volume, 1), 0);
|
|
178
183
|
}
|
|
179
184
|
}
|
|
180
|
-
async fadeToVolume(
|
|
185
|
+
async fadeToVolume(targetVolume) {
|
|
181
186
|
return new Promise((resolve, reject) => {
|
|
182
187
|
this.fadeCancelEvent.next();
|
|
183
|
-
this.volume = volume;
|
|
184
188
|
const fadeOutInterval = 100;
|
|
185
189
|
const fadeOutSteps = this.options.crossfadeTime / fadeOutInterval;
|
|
186
|
-
const fadeOutStep = (
|
|
190
|
+
const fadeOutStep = (targetVolume - this.playerElement.volume) / fadeOutSteps;
|
|
187
191
|
if (fadeOutStep === 0)
|
|
188
192
|
return resolve();
|
|
189
193
|
interval(fadeOutInterval)
|
|
@@ -196,12 +200,22 @@ export class PlayerController {
|
|
|
196
200
|
},
|
|
197
201
|
error: (error) => reject(error),
|
|
198
202
|
complete: () => {
|
|
199
|
-
this.playerElement.volume =
|
|
203
|
+
this.playerElement.volume = targetVolume;
|
|
200
204
|
resolve();
|
|
201
205
|
},
|
|
202
206
|
});
|
|
203
207
|
});
|
|
204
208
|
}
|
|
209
|
+
async fadeOut() {
|
|
210
|
+
await this.fadeToVolume(0);
|
|
211
|
+
this.playerElement.pause();
|
|
212
|
+
this.playerElement.volume = this.volume;
|
|
213
|
+
}
|
|
214
|
+
async fadeIn() {
|
|
215
|
+
this.playerElement.volume = 0.01;
|
|
216
|
+
this.playerElement.play();
|
|
217
|
+
await this.fadeToVolume(this.volume);
|
|
218
|
+
}
|
|
205
219
|
back(seconds = 10) {
|
|
206
220
|
const position = this.playerElement.currentTime;
|
|
207
221
|
this.seekTo(Math.max(position - seconds, 0));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@audiowalk/sdk",
|
|
3
|
-
"version": "2.0.0-rc",
|
|
3
|
+
"version": "2.0.0-rc.2",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/audiowalk-cz/components.git"
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
"build": "tsc",
|
|
17
17
|
"build:watch": "tsc -w",
|
|
18
18
|
"prepublishOnly": "npm run build",
|
|
19
|
+
"release": "git switch release && git merge master --ff-only && git push --follow-tags && git switch master",
|
|
19
20
|
"release:patch": "git switch master && npm version patch && git switch release && git merge master --ff-only && git push --follow-tags && git switch master && git push",
|
|
20
21
|
"release:minor": "git switch master && npm version minor && git switch release && git merge master --ff-only && git push --follow-tags && git switch master && git push",
|
|
21
22
|
"release:major": "git switch master && npm version major && git switch release && git merge master --ff-only && git push --follow-tags && git switch master && git push"
|
|
@@ -30,4 +31,4 @@
|
|
|
30
31
|
"axios": "^1.7.7",
|
|
31
32
|
"rxjs": "^7.8.1"
|
|
32
33
|
}
|
|
33
|
-
}
|
|
34
|
+
}
|