@audiowalk/sdk
Advanced tools
Comparing version 1.1.2 to 1.2.1
export * from "./player/player-controller"; | ||
export * from "./storage/local-storage"; | ||
//# sourceMappingURL=index.d.ts.map |
export * from "./player/player-controller"; | ||
export * from "./storage/local-storage"; |
@@ -23,4 +23,5 @@ import { BehaviorSubject, Subject } from "rxjs"; | ||
private file?; | ||
private localStorage; | ||
constructor(playerElement: HTMLAudioElement, options?: PlayerControllerOptions); | ||
open(file: string, metadata: MediaMetadataInit): void; | ||
open(file: string, metadata: MediaMetadataInit): Promise<void>; | ||
close(): void; | ||
@@ -30,4 +31,4 @@ play(): void; | ||
seekTo(seconds: number): void; | ||
back(): void; | ||
forward(): void; | ||
back(seconds?: number): void; | ||
forward(seconds?: number): void; | ||
private savePosition; | ||
@@ -34,0 +35,0 @@ private log; |
import { BehaviorSubject, combineLatest, map, Subject } from "rxjs"; | ||
import { LocalStorage } from "../storage/local-storage"; | ||
export var PlayerStatus; | ||
@@ -20,2 +21,3 @@ (function (PlayerStatus) { | ||
file; | ||
localStorage = new LocalStorage(); | ||
constructor(playerElement, options = {}) { | ||
@@ -80,10 +82,10 @@ this.playerElement = playerElement; | ||
} | ||
open(file, metadata) { | ||
async open(file, metadata) { | ||
this.file = file; | ||
navigator.mediaSession.metadata = new MediaMetadata(metadata); | ||
const position = localStorage.getItem(`progress-${this.file}`); | ||
const position = await this.localStorage.get(`progress-${this.file}`); | ||
if (position && this.options.autoSave) | ||
this.playerElement.currentTime = parseFloat(position); | ||
if (this.options.playOnInit) | ||
this.playerElement.play(); | ||
await this.playerElement.play(); | ||
} | ||
@@ -119,9 +121,9 @@ close() { | ||
} | ||
back() { | ||
back(seconds = 10) { | ||
if (!this.file) | ||
throw new Error("No file opened"); | ||
const position = this.playerElement.currentTime; | ||
this.seekTo(Math.max(position - 10, 0)); | ||
this.seekTo(Math.max(position - seconds, 0)); | ||
} | ||
forward() { | ||
forward(seconds = 10) { | ||
if (!this.file) | ||
@@ -131,8 +133,8 @@ throw new Error("No file opened"); | ||
const duration = this.playerElement.duration; | ||
this.seekTo(duration && duration > 0 ? Math.min(position + 10, duration) : position + 10); | ||
this.seekTo(duration && duration > 0 ? Math.min(position + seconds, duration) : position + seconds); | ||
} | ||
savePosition(currentTime) { | ||
async savePosition(currentTime) { | ||
if (!this.file) | ||
return; | ||
localStorage.setItem(`progress-${this.file}`, String(currentTime)); | ||
await this.localStorage.set(`progress-${this.file}`, String(currentTime)); | ||
} | ||
@@ -139,0 +141,0 @@ log(message) { |
{ | ||
"name": "@audiowalk/sdk", | ||
"version": "1.1.2", | ||
"version": "1.2.1", | ||
"repository": { | ||
@@ -8,15 +8,3 @@ "type": "git", | ||
}, | ||
"exports": { | ||
".": { | ||
"import": "./dist/index.js", | ||
"require": "./dist/index.js" | ||
}, | ||
"./package.json": "./package.json", | ||
"./angular": { | ||
"types": "./angular/dist/index.d.ts", | ||
"esm2022": "./angular/dist/esm2022/audiowalk-components.mjs", | ||
"esm": "./angular/dist/esm2022/audiowalk-components.mjs", | ||
"default": "./angular/dist/fesm2022/audiowalk-components.mjs" | ||
} | ||
}, | ||
"exports": "./dist/index.js", | ||
"files": [ | ||
@@ -29,5 +17,3 @@ "dist", | ||
"dev": "tsc -w", | ||
"build": "concurrently --kill-others-on-fail --names core,angular \"npm run build:core\" \"npm run build:angular\"", | ||
"build:core": "tsc", | ||
"build:angular": "cd angular && npm run build", | ||
"build": "tsc", | ||
"prepublishOnly": "npm run build", | ||
@@ -34,0 +20,0 @@ "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", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
210
10767
10
2
0