@audiowalk/sdk
Advanced tools
Comparing version 1.5.1 to 1.5.2
@@ -40,2 +40,3 @@ import { BehaviorSubject, Subject } from "rxjs"; | ||
fadeOut(): Promise<void>; | ||
private clearFade; | ||
pause(options?: { | ||
@@ -42,0 +43,0 @@ fadeIn?: boolean; |
@@ -62,2 +62,3 @@ import { BehaviorSubject, combineLatest, map, Subject, take, takeUntil, takeWhile } from "rxjs"; | ||
.subscribe(async (currentTime) => { | ||
this.onStop.next(); | ||
this.fadeOut(); | ||
@@ -91,3 +92,3 @@ }); | ||
this.log("Called play"); | ||
this.playerElement?.play(); | ||
await this.playerElement?.play(); | ||
if (options.fadeIn !== undefined ? options.fadeIn : this.options.fadeIn) | ||
@@ -97,6 +98,3 @@ await this.fadeIn(); | ||
async fadeIn() { | ||
if (!this.options.fadeInterval) { | ||
clearInterval(this.fadeIntervalSubscription); | ||
this.fadePromiseResolve?.(); | ||
} | ||
this.clearFade(); | ||
return new Promise((resolve) => { | ||
@@ -110,3 +108,3 @@ this.playerElement.volume = 0; | ||
} | ||
this.playerElement.volume += (1 / this.options.fadeInterval) * 100; | ||
this.playerElement.volume = Math.min(this.playerElement.volume + (1 / this.options.fadeInterval) * 100, 1); | ||
}, 100); | ||
@@ -116,6 +114,3 @@ }); | ||
async fadeOut() { | ||
if (!this.options.fadeInterval) { | ||
clearInterval(this.fadeIntervalSubscription); | ||
this.fadePromiseResolve?.(); | ||
} | ||
this.clearFade(); | ||
return new Promise((resolve) => { | ||
@@ -129,6 +124,10 @@ this.fadePromiseResolve = resolve; | ||
} | ||
this.playerElement.volume -= (1 / this.options.fadeInterval) * 100; | ||
this.playerElement.volume = Math.max(this.playerElement.volume - (1 / this.options.fadeInterval) * 100, 0); | ||
}, 100); | ||
}); | ||
} | ||
clearFade() { | ||
clearInterval(this.fadeIntervalSubscription); | ||
this.fadePromiseResolve?.(); | ||
} | ||
async pause(options = {}) { | ||
@@ -135,0 +134,0 @@ if (!this.playerElement.src) |
{ | ||
"name": "@audiowalk/sdk", | ||
"version": "1.5.1", | ||
"version": "1.5.2", | ||
"repository": { | ||
@@ -5,0 +5,0 @@ "type": "git", |
Sorry, the diff of this file is not supported yet
23755