@audiowalk/sdk 1.1.2 → 1.2.1
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/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/player/player-controller.d.ts +4 -3
- package/dist/player/player-controller.d.ts.map +1 -1
- package/dist/player/player-controller.js +11 -9
- package/dist/storage/local-storage.d.ts +11 -0
- package/dist/storage/local-storage.d.ts.map +1 -0
- package/dist/storage/local-storage.js +19 -0
- package/package.json +3 -17
- package/angular/dist/README.md +0 -3
- package/angular/dist/esm2022/audiowalk-angular.mjs +0 -5
- package/angular/dist/esm2022/main.mjs +0 -2
- package/angular/dist/fesm2022/audiowalk-angular.mjs +0 -8
- package/angular/dist/fesm2022/audiowalk-angular.mjs.map +0 -1
- package/angular/dist/index.d.ts +0 -5
- package/angular/dist/main.d.ts +0 -1
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAC;AAC3C,cAAc,yBAAyB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -20,14 +20,15 @@ export declare class PlayerController {
|
|
|
20
20
|
readonly status: BehaviorSubject<PlayerStatus | null>;
|
|
21
21
|
readonly playing: import("rxjs").Observable<boolean>;
|
|
22
22
|
private file?;
|
|
23
|
+
private localStorage;
|
|
23
24
|
constructor(playerElement: HTMLAudioElement, options?: PlayerControllerOptions);
|
|
24
|
-
open(file: string, metadata: MediaMetadataInit): void
|
|
25
|
+
open(file: string, metadata: MediaMetadataInit): Promise<void>;
|
|
25
26
|
close(): void;
|
|
26
27
|
play(): void;
|
|
27
28
|
pause(): void;
|
|
28
29
|
seekTo(seconds: number): void;
|
|
29
|
-
back(): void;
|
|
30
|
-
forward(): void;
|
|
30
|
+
back(seconds?: number): void;
|
|
31
|
+
forward(seconds?: number): void;
|
|
31
32
|
private savePosition;
|
|
32
33
|
private log;
|
|
33
34
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"player-controller.d.ts","sourceRoot":"","sources":["../../src/player/player-controller.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAsB,OAAO,EAAE,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"player-controller.d.ts","sourceRoot":"","sources":["../../src/player/player-controller.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAsB,OAAO,EAAE,MAAM,MAAM,CAAC;AAGpE,MAAM,WAAW,uBAAuB;IACtC,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,oBAAY,YAAY;IACtB,SAAS,YAAY;IACrB,QAAQ,WAAW;IACnB,OAAO,UAAU;CAClB;AAED,qBAAa,gBAAgB;IAmBf,OAAO,CAAC,QAAQ,CAAC,aAAa;IAAoB,OAAO,CAAC,OAAO;IAlB7E,SAAgB,MAAM,gBAAuB;IAC7C,SAAgB,OAAO,gBAAuB;IAC9C,SAAgB,MAAM,gBAAuB;IAE7C,SAAgB,WAAW,0BAAkC;IAC7D,SAAgB,SAAS,0BAAkC;IAC3D,SAAgB,QAAQ,oCAEtB;IAEF,SAAgB,MAAM,uCAAkD;IAExE,SAAgB,OAAO,qCAA2D;IAElF,OAAO,CAAC,IAAI,CAAC,CAAS;IAEtB,OAAO,CAAC,YAAY,CAAsB;gBAEb,aAAa,EAAE,gBAAgB,EAAU,OAAO,GAAE,uBAA4B;IAmErG,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,iBAAiB;IAWpD,KAAK;IAaL,IAAI;IAOJ,KAAK;IAML,MAAM,CAAC,OAAO,EAAE,MAAM;IAOtB,IAAI,CAAC,OAAO,GAAE,MAAW;IAOzB,OAAO,CAAC,OAAO,GAAE,MAAW;YAQd,YAAY;IAK1B,OAAO,CAAC,GAAG;CAOZ"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { BehaviorSubject, combineLatest, map, Subject } from "rxjs";
|
|
2
|
+
import { LocalStorage } from "../storage/local-storage";
|
|
2
3
|
export var PlayerStatus;
|
|
3
4
|
(function (PlayerStatus) {
|
|
4
5
|
PlayerStatus["playing"] = "playing";
|
|
@@ -17,6 +18,7 @@ export class PlayerController {
|
|
|
17
18
|
status = new BehaviorSubject(null);
|
|
18
19
|
playing = this.status.pipe(map((status) => status === "playing"));
|
|
19
20
|
file;
|
|
21
|
+
localStorage = new LocalStorage();
|
|
20
22
|
constructor(playerElement, options = {}) {
|
|
21
23
|
this.playerElement = playerElement;
|
|
22
24
|
this.options = options;
|
|
@@ -76,14 +78,14 @@ export class PlayerController {
|
|
|
76
78
|
this.savePosition(this.playerElement.currentTime);
|
|
77
79
|
});
|
|
78
80
|
}
|
|
79
|
-
open(file, metadata) {
|
|
81
|
+
async open(file, metadata) {
|
|
80
82
|
this.file = file;
|
|
81
83
|
navigator.mediaSession.metadata = new MediaMetadata(metadata);
|
|
82
|
-
const position = localStorage.
|
|
84
|
+
const position = await this.localStorage.get(`progress-${this.file}`);
|
|
83
85
|
if (position && this.options.autoSave)
|
|
84
86
|
this.playerElement.currentTime = parseFloat(position);
|
|
85
87
|
if (this.options.playOnInit)
|
|
86
|
-
this.playerElement.play();
|
|
88
|
+
await this.playerElement.play();
|
|
87
89
|
}
|
|
88
90
|
close() {
|
|
89
91
|
this.file = undefined;
|
|
@@ -114,23 +116,23 @@ export class PlayerController {
|
|
|
114
116
|
this.log("Called seekTo");
|
|
115
117
|
this.playerElement.currentTime = seconds;
|
|
116
118
|
}
|
|
117
|
-
back() {
|
|
119
|
+
back(seconds = 10) {
|
|
118
120
|
if (!this.file)
|
|
119
121
|
throw new Error("No file opened");
|
|
120
122
|
const position = this.playerElement.currentTime;
|
|
121
|
-
this.seekTo(Math.max(position -
|
|
123
|
+
this.seekTo(Math.max(position - seconds, 0));
|
|
122
124
|
}
|
|
123
|
-
forward() {
|
|
125
|
+
forward(seconds = 10) {
|
|
124
126
|
if (!this.file)
|
|
125
127
|
throw new Error("No file opened");
|
|
126
128
|
const position = this.playerElement.currentTime;
|
|
127
129
|
const duration = this.playerElement.duration;
|
|
128
|
-
this.seekTo(duration && duration > 0 ? Math.min(position +
|
|
130
|
+
this.seekTo(duration && duration > 0 ? Math.min(position + seconds, duration) : position + seconds);
|
|
129
131
|
}
|
|
130
|
-
savePosition(currentTime) {
|
|
132
|
+
async savePosition(currentTime) {
|
|
131
133
|
if (!this.file)
|
|
132
134
|
return;
|
|
133
|
-
localStorage.
|
|
135
|
+
await this.localStorage.set(`progress-${this.file}`, String(currentTime));
|
|
134
136
|
}
|
|
135
137
|
log(message) {
|
|
136
138
|
const time = this.playerElement?.currentTime ? Math.round(this.playerElement?.currentTime) : null;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface LocalStorageOptions {
|
|
2
|
+
prefix?: string;
|
|
3
|
+
}
|
|
4
|
+
export declare class LocalStorage {
|
|
5
|
+
private options;
|
|
6
|
+
constructor(options?: Partial<LocalStorageOptions>);
|
|
7
|
+
get(key: string): Promise<string | null>;
|
|
8
|
+
set(key: string, value: any): Promise<void>;
|
|
9
|
+
private getPrefixedKey;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=local-storage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"local-storage.d.ts","sourceRoot":"","sources":["../../src/storage/local-storage.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,mBAAmB;IAClC,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,qBAAa,YAAY;IACX,OAAO,CAAC,OAAO;gBAAP,OAAO,GAAE,OAAO,CAAC,mBAAmB,CAAM;IAExD,GAAG,CAAC,GAAG,EAAE,MAAM;IAIf,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG;IAIjC,OAAO,CAAC,cAAc;CAQvB"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export class LocalStorage {
|
|
2
|
+
options;
|
|
3
|
+
constructor(options = {}) {
|
|
4
|
+
this.options = options;
|
|
5
|
+
}
|
|
6
|
+
async get(key) {
|
|
7
|
+
return window.localStorage.getItem(this.getPrefixedKey(key));
|
|
8
|
+
}
|
|
9
|
+
async set(key, value) {
|
|
10
|
+
return window.localStorage.setItem(this.getPrefixedKey(key), value);
|
|
11
|
+
}
|
|
12
|
+
getPrefixedKey(key) {
|
|
13
|
+
const keyParts = ["audiowalk"];
|
|
14
|
+
if (this.options.prefix)
|
|
15
|
+
keyParts.push(this.options.prefix);
|
|
16
|
+
keyParts.push(key);
|
|
17
|
+
return keyParts.join("-");
|
|
18
|
+
}
|
|
19
|
+
}
|
package/package.json
CHANGED
|
@@ -1,23 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@audiowalk/sdk",
|
|
3
|
-
"version": "1.1
|
|
3
|
+
"version": "1.2.1",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/audiowalk-cz/components.git"
|
|
7
7
|
},
|
|
8
|
-
"exports":
|
|
9
|
-
".": {
|
|
10
|
-
"import": "./dist/index.js",
|
|
11
|
-
"require": "./dist/index.js"
|
|
12
|
-
},
|
|
13
|
-
"./package.json": "./package.json",
|
|
14
|
-
"./angular": {
|
|
15
|
-
"types": "./angular/dist/index.d.ts",
|
|
16
|
-
"esm2022": "./angular/dist/esm2022/audiowalk-components.mjs",
|
|
17
|
-
"esm": "./angular/dist/esm2022/audiowalk-components.mjs",
|
|
18
|
-
"default": "./angular/dist/fesm2022/audiowalk-components.mjs"
|
|
19
|
-
}
|
|
20
|
-
},
|
|
8
|
+
"exports": "./dist/index.js",
|
|
21
9
|
"files": [
|
|
22
10
|
"dist",
|
|
23
11
|
"angular/dist"
|
|
@@ -25,9 +13,7 @@
|
|
|
25
13
|
"type": "module",
|
|
26
14
|
"scripts": {
|
|
27
15
|
"dev": "tsc -w",
|
|
28
|
-
"build": "
|
|
29
|
-
"build:core": "tsc",
|
|
30
|
-
"build:angular": "cd angular && npm run build",
|
|
16
|
+
"build": "tsc",
|
|
31
17
|
"prepublishOnly": "npm run build",
|
|
32
18
|
"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",
|
|
33
19
|
"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",
|
package/angular/dist/README.md
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Generated bundle index. Do not edit.
|
|
3
|
-
*/
|
|
4
|
-
export * from './main';
|
|
5
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYXVkaW93YWxrLWFuZ3VsYXIuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvYXVkaW93YWxrLWFuZ3VsYXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7O0dBRUc7QUFFSCxjQUFjLFFBQVEsQ0FBQyIsInNvdXJjZXNDb250ZW50IjpbIi8qKlxuICogR2VuZXJhdGVkIGJ1bmRsZSBpbmRleC4gRG8gbm90IGVkaXQuXG4gKi9cblxuZXhwb3J0ICogZnJvbSAnLi9tYWluJztcbiJdfQ==
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
export const DUMMY_EXPORT = 5;
|
|
2
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibWFpbi5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9tYWluLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE1BQU0sQ0FBQyxNQUFNLFlBQVksR0FBRyxDQUFDLENBQUMiLCJzb3VyY2VzQ29udGVudCI6WyJleHBvcnQgY29uc3QgRFVNTVlfRVhQT1JUID0gNTtcbiJdfQ==
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"audiowalk-angular.mjs","sources":["../../src/main.ts","../../src/audiowalk-angular.ts"],"sourcesContent":["export const DUMMY_EXPORT = 5;\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './main';\n"],"names":[],"mappings":"AAAO,MAAM,YAAY,GAAG;;ACA5B;;AAEG;;;;"}
|
package/angular/dist/index.d.ts
DELETED
package/angular/dist/main.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const DUMMY_EXPORT = 5;
|