@bizy/core 19.11.20 → 19.11.21
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/fesm2022/bizy-core.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { EventEmitter, ChangeDetectorRef, Output, Input, Inject, ChangeDetectionStrategy, Component, NgModule, Renderer2, ElementRef, Injectable, Directive, ViewChild, ContentChildren,
|
|
2
|
+
import { EventEmitter, ChangeDetectorRef, Output, Input, Inject, ChangeDetectionStrategy, Component, NgModule, inject, Renderer2, ElementRef, Injectable, Directive, ViewChild, ContentChildren, ContentChild, RendererFactory2, Pipe, ViewContainerRef, TemplateRef, HostListener, Host } from '@angular/core';
|
|
3
3
|
import * as i1 from '@angular/common';
|
|
4
4
|
import { CommonModule, DOCUMENT, registerLocaleData, DatePipe } from '@angular/common';
|
|
5
5
|
import { Subject, Subscription, BehaviorSubject, filter, take, skip, auditTime, throttleTime, debounceTime as debounceTime$1, interval, fromEvent, merge, timer, of } from 'rxjs';
|
|
@@ -153,10 +153,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.8", ngImpor
|
|
|
153
153
|
}] });
|
|
154
154
|
|
|
155
155
|
class BizyAudioPlayerComponent {
|
|
156
|
-
document;
|
|
157
|
-
renderer;
|
|
156
|
+
#document = inject(DOCUMENT);
|
|
157
|
+
#renderer = inject(Renderer2);
|
|
158
158
|
id = `bizy-audio-player-${Math.random()}`;
|
|
159
|
-
mimeType
|
|
159
|
+
mimeType;
|
|
160
160
|
showDownload = true;
|
|
161
161
|
autoplay = false;
|
|
162
162
|
downloadURL;
|
|
@@ -168,77 +168,96 @@ class BizyAudioPlayerComponent {
|
|
|
168
168
|
return;
|
|
169
169
|
}
|
|
170
170
|
this._audioURL = audioURL;
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
171
|
+
if (!this.mimeType) {
|
|
172
|
+
const isOGG = this._audioURL.toLowerCase().includes('ogg');
|
|
173
|
+
if (isOGG) {
|
|
174
|
+
this.mimeType = MIME_TYPE.OGG;
|
|
175
|
+
}
|
|
176
|
+
else {
|
|
177
|
+
const isWAV = this._audioURL.toLowerCase().includes('wav');
|
|
178
|
+
if (isWAV) {
|
|
179
|
+
this.mimeType = MIME_TYPE.WAV;
|
|
180
|
+
}
|
|
181
|
+
else {
|
|
182
|
+
this.mimeType = MIME_TYPE.MPEG;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
this.#audioRef = this.#document.getElementById(this.id);
|
|
187
|
+
if (this.#audioRef) {
|
|
188
|
+
this.#audioRef.load();
|
|
174
189
|
if (this.autoplay) {
|
|
175
|
-
this.
|
|
190
|
+
this.#audioRef.play();
|
|
176
191
|
}
|
|
177
192
|
}
|
|
193
|
+
else {
|
|
194
|
+
const interval = setInterval(() => {
|
|
195
|
+
this.#audioRef = this.#document.getElementById(this.id);
|
|
196
|
+
if (this.#audioRef) {
|
|
197
|
+
this.#audioRef.load();
|
|
198
|
+
if (this.autoplay) {
|
|
199
|
+
this.#audioRef.play();
|
|
200
|
+
}
|
|
201
|
+
clearInterval(interval);
|
|
202
|
+
}
|
|
203
|
+
}, 300);
|
|
204
|
+
}
|
|
178
205
|
}
|
|
179
206
|
_audioURL = null;
|
|
180
|
-
|
|
207
|
+
#audioRef;
|
|
181
208
|
_playbackRate = 1;
|
|
182
209
|
#trackPlaybackRate$ = new Subject();
|
|
183
210
|
#subscription = new Subscription();
|
|
184
|
-
constructor(document, renderer) {
|
|
185
|
-
this.document = document;
|
|
186
|
-
this.renderer = renderer;
|
|
187
|
-
}
|
|
188
211
|
trackPlayerRate() {
|
|
189
212
|
this.#subscription.add(this.#trackPlaybackRate$.pipe(debounceTime(500), distinctUntilChanged()).subscribe(value => {
|
|
190
213
|
this.onTrackPlayerRate.emit(value);
|
|
191
214
|
}));
|
|
192
215
|
}
|
|
193
216
|
_onTrackPlayerRate() {
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
217
|
+
if (!this.#audioRef) {
|
|
218
|
+
this.#audioRef = this.#document.getElementById(this.id);
|
|
219
|
+
}
|
|
220
|
+
if (this.#audioRef) {
|
|
221
|
+
switch (this.#audioRef.playbackRate) {
|
|
197
222
|
case 1:
|
|
198
|
-
this.
|
|
223
|
+
this.#audioRef.playbackRate = 1.5;
|
|
199
224
|
this._playbackRate = 1.5;
|
|
200
225
|
this.#trackPlaybackRate$.next('1.5');
|
|
201
226
|
break;
|
|
202
227
|
case 1.5:
|
|
203
|
-
this.
|
|
228
|
+
this.#audioRef.playbackRate = 2;
|
|
204
229
|
this._playbackRate = 2;
|
|
205
230
|
this.#trackPlaybackRate$.next('2');
|
|
206
231
|
break;
|
|
207
232
|
case 2:
|
|
208
|
-
this.
|
|
233
|
+
this.#audioRef.playbackRate = 1;
|
|
209
234
|
this._playbackRate = 1;
|
|
210
235
|
break;
|
|
211
236
|
default:
|
|
212
|
-
this.
|
|
237
|
+
this.#audioRef.playbackRate = 1;
|
|
213
238
|
this._playbackRate = 1;
|
|
214
239
|
}
|
|
215
240
|
}
|
|
216
241
|
}
|
|
217
242
|
_onDownload() {
|
|
218
|
-
const downloadButton = this
|
|
219
|
-
this
|
|
220
|
-
this
|
|
221
|
-
this
|
|
243
|
+
const downloadButton = this.#renderer.createElement('a');
|
|
244
|
+
this.#renderer.setAttribute(downloadButton, 'download', this.downloadFileName);
|
|
245
|
+
this.#renderer.setProperty(downloadButton, 'href', this.downloadURL);
|
|
246
|
+
this.#renderer.appendChild(this.#document.body, downloadButton);
|
|
222
247
|
downloadButton.click();
|
|
223
|
-
this
|
|
248
|
+
this.#renderer.removeChild(this.#document.body, downloadButton);
|
|
224
249
|
this.onDownload.emit();
|
|
225
250
|
}
|
|
226
251
|
ngOnDestroy() {
|
|
227
252
|
this.#subscription.unsubscribe();
|
|
228
253
|
}
|
|
229
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: BizyAudioPlayerComponent, deps: [
|
|
230
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.8", type: BizyAudioPlayerComponent, isStandalone: true, selector: "bizy-audio-player", inputs: { id: "id", mimeType: "mimeType", showDownload: "showDownload", autoplay: "autoplay", downloadURL: "downloadURL", downloadFileName: "downloadFileName", audioURL: "audioURL" }, outputs: { onDownload: "onDownload", onTrackPlayerRate: "onTrackPlayerRate" }, ngImport: i0, template: "<div class=\"bizy-audio-player-component\">\n\n <span class=\"bizy-audio-player__audio-controls\">\n\n <audio\n *ngIf=\"_audioURL\"\n class=\"bizy-audio-player__audio-controls__audio\"\n [id]=\"id\"\n [autoplay]=\"autoplay\"\n controls\n controlslist=\"nodownload noplaybackrate\">\n <source [src]=\"_audioURL\" [type]=\"mimeType\">\n {{audioPlayerError}}\n </audio>\n\n <bizy-button customClass=\"bizy-audio-player__audio-controls__playback-rate\" (onSelect)=\"_onTrackPlayerRate()\">\n <span>{{_playbackRate}}x</span>\n </bizy-button>\n\n <bizy-button customClass=\"bizy-audio-player__download-button\" *ngIf=\"showDownload\" (onSelect)=\"_onDownload()\">\n <svg \n class=\"bizy-audio-player__download-button__icon\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n stroke-width=\"2\"\n viewBox=\"0 0 24 24\"\n xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4\"/><polyline points=\"7 10 12 15 17 10\"/><line x1=\"12\" x2=\"12\" y1=\"15\" y2=\"3\"/>\n </svg>\n </bizy-button>\n\n </span>\n\n</div>", styles: [":host{font-size:1rem}.bizy-audio-player-component{width:100%;display:flex;flex-direction:column;justify-content:center;align-items:center;row-gap:2rem}.bizy-audio-player__audio-controls{width:100%;display:flex;align-items:center;column-gap:1rem}.bizy-audio-player__audio-controls__audio{flex:1;width:100%}::ng-deep .bizy-audio-player__audio-controls__playback-rate{font-size:1rem;--bizy-button-background-color: var(--bizy-audio-player-playback-rate-background-color);--bizy-button-color: var(--bizy-audio-player-playback-rate-color);font-weight:700;border-radius:50%!important;width:4rem;height:2rem;display:grid;place-items:center;cursor:pointer}::ng-deep .bizy-audio-player__download-button{--bizy-button-background-color: var(--bizy-audio-player-download-button-background-color);--bizy-button-color: var(--bizy-audio-player-download-button-color)}.bizy-audio-player__download-button__icon{height:1rem}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "ngmodule", type: BizyButtonModule }, { kind: "component", type: BizyButtonComponent, selector: "bizy-button", inputs: ["id", "disabled", "type", "customClass"], outputs: ["onSelect"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
254
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: BizyAudioPlayerComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
255
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.8", type: BizyAudioPlayerComponent, isStandalone: true, selector: "bizy-audio-player", inputs: { id: "id", mimeType: "mimeType", showDownload: "showDownload", autoplay: "autoplay", downloadURL: "downloadURL", downloadFileName: "downloadFileName", audioURL: "audioURL" }, outputs: { onDownload: "onDownload", onTrackPlayerRate: "onTrackPlayerRate" }, ngImport: i0, template: "<div class=\"bizy-audio-player-component\">\n\n <span class=\"bizy-audio-player__audio-controls\">\n\n <audio\n *ngIf=\"_audioURL\"\n class=\"bizy-audio-player__audio-controls__audio\"\n [id]=\"id\"\n [autoplay]=\"autoplay\"\n controls\n controlslist=\"nodownload noplaybackrate\">\n <source [src]=\"_audioURL\" [type]=\"mimeType\">\n {{audioPlayerError}}\n </audio>\n\n <bizy-button customClass=\"bizy-audio-player__audio-controls__playback-rate\" (onSelect)=\"_onTrackPlayerRate()\">\n <span>{{_playbackRate}}x</span>\n </bizy-button>\n\n <bizy-button customClass=\"bizy-audio-player__download-button\" *ngIf=\"showDownload\" (onSelect)=\"_onDownload()\">\n <svg \n class=\"bizy-audio-player__download-button__icon\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n stroke-width=\"2\"\n viewBox=\"0 0 24 24\"\n xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4\"/><polyline points=\"7 10 12 15 17 10\"/><line x1=\"12\" x2=\"12\" y1=\"15\" y2=\"3\"/>\n </svg>\n </bizy-button>\n\n </span>\n\n</div>", styles: [":host{font-size:1rem;width:100%}.bizy-audio-player-component{width:100%;display:flex;flex-direction:column;justify-content:center;align-items:center;row-gap:2rem}.bizy-audio-player__audio-controls{width:100%;min-width:25rem;display:flex;align-items:center;column-gap:1rem}.bizy-audio-player__audio-controls__audio{flex:1;width:100%}::ng-deep .bizy-audio-player__audio-controls__playback-rate{font-size:1rem;--bizy-button-background-color: var(--bizy-audio-player-playback-rate-background-color);--bizy-button-color: var(--bizy-audio-player-playback-rate-color);font-weight:700;border-radius:50%!important;width:4rem;height:2rem;display:grid;place-items:center;cursor:pointer}::ng-deep .bizy-audio-player__download-button{--bizy-button-background-color: var(--bizy-audio-player-download-button-background-color);--bizy-button-color: var(--bizy-audio-player-download-button-color)}.bizy-audio-player__download-button__icon{height:1rem}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "ngmodule", type: BizyButtonModule }, { kind: "component", type: BizyButtonComponent, selector: "bizy-button", inputs: ["id", "disabled", "type", "customClass"], outputs: ["onSelect"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
231
256
|
}
|
|
232
257
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.8", ngImport: i0, type: BizyAudioPlayerComponent, decorators: [{
|
|
233
258
|
type: Component,
|
|
234
|
-
args: [{ selector: 'bizy-audio-player', imports: [CommonModule, BizyButtonModule], changeDetection: ChangeDetectionStrategy.OnPush, template: "<div class=\"bizy-audio-player-component\">\n\n <span class=\"bizy-audio-player__audio-controls\">\n\n <audio\n *ngIf=\"_audioURL\"\n class=\"bizy-audio-player__audio-controls__audio\"\n [id]=\"id\"\n [autoplay]=\"autoplay\"\n controls\n controlslist=\"nodownload noplaybackrate\">\n <source [src]=\"_audioURL\" [type]=\"mimeType\">\n {{audioPlayerError}}\n </audio>\n\n <bizy-button customClass=\"bizy-audio-player__audio-controls__playback-rate\" (onSelect)=\"_onTrackPlayerRate()\">\n <span>{{_playbackRate}}x</span>\n </bizy-button>\n\n <bizy-button customClass=\"bizy-audio-player__download-button\" *ngIf=\"showDownload\" (onSelect)=\"_onDownload()\">\n <svg \n class=\"bizy-audio-player__download-button__icon\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n stroke-width=\"2\"\n viewBox=\"0 0 24 24\"\n xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4\"/><polyline points=\"7 10 12 15 17 10\"/><line x1=\"12\" x2=\"12\" y1=\"15\" y2=\"3\"/>\n </svg>\n </bizy-button>\n\n </span>\n\n</div>", styles: [":host{font-size:1rem}.bizy-audio-player-component{width:100%;display:flex;flex-direction:column;justify-content:center;align-items:center;row-gap:2rem}.bizy-audio-player__audio-controls{width:100%;display:flex;align-items:center;column-gap:1rem}.bizy-audio-player__audio-controls__audio{flex:1;width:100%}::ng-deep .bizy-audio-player__audio-controls__playback-rate{font-size:1rem;--bizy-button-background-color: var(--bizy-audio-player-playback-rate-background-color);--bizy-button-color: var(--bizy-audio-player-playback-rate-color);font-weight:700;border-radius:50%!important;width:4rem;height:2rem;display:grid;place-items:center;cursor:pointer}::ng-deep .bizy-audio-player__download-button{--bizy-button-background-color: var(--bizy-audio-player-download-button-background-color);--bizy-button-color: var(--bizy-audio-player-download-button-color)}.bizy-audio-player__download-button__icon{height:1rem}\n"] }]
|
|
235
|
-
}],
|
|
236
|
-
type: Inject,
|
|
237
|
-
args: [DOCUMENT]
|
|
238
|
-
}] }, { type: i0.Renderer2, decorators: [{
|
|
239
|
-
type: Inject,
|
|
240
|
-
args: [Renderer2]
|
|
241
|
-
}] }], propDecorators: { id: [{
|
|
259
|
+
args: [{ selector: 'bizy-audio-player', imports: [CommonModule, BizyButtonModule], changeDetection: ChangeDetectionStrategy.OnPush, template: "<div class=\"bizy-audio-player-component\">\n\n <span class=\"bizy-audio-player__audio-controls\">\n\n <audio\n *ngIf=\"_audioURL\"\n class=\"bizy-audio-player__audio-controls__audio\"\n [id]=\"id\"\n [autoplay]=\"autoplay\"\n controls\n controlslist=\"nodownload noplaybackrate\">\n <source [src]=\"_audioURL\" [type]=\"mimeType\">\n {{audioPlayerError}}\n </audio>\n\n <bizy-button customClass=\"bizy-audio-player__audio-controls__playback-rate\" (onSelect)=\"_onTrackPlayerRate()\">\n <span>{{_playbackRate}}x</span>\n </bizy-button>\n\n <bizy-button customClass=\"bizy-audio-player__download-button\" *ngIf=\"showDownload\" (onSelect)=\"_onDownload()\">\n <svg \n class=\"bizy-audio-player__download-button__icon\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n stroke-width=\"2\"\n viewBox=\"0 0 24 24\"\n xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4\"/><polyline points=\"7 10 12 15 17 10\"/><line x1=\"12\" x2=\"12\" y1=\"15\" y2=\"3\"/>\n </svg>\n </bizy-button>\n\n </span>\n\n</div>", styles: [":host{font-size:1rem;width:100%}.bizy-audio-player-component{width:100%;display:flex;flex-direction:column;justify-content:center;align-items:center;row-gap:2rem}.bizy-audio-player__audio-controls{width:100%;min-width:25rem;display:flex;align-items:center;column-gap:1rem}.bizy-audio-player__audio-controls__audio{flex:1;width:100%}::ng-deep .bizy-audio-player__audio-controls__playback-rate{font-size:1rem;--bizy-button-background-color: var(--bizy-audio-player-playback-rate-background-color);--bizy-button-color: var(--bizy-audio-player-playback-rate-color);font-weight:700;border-radius:50%!important;width:4rem;height:2rem;display:grid;place-items:center;cursor:pointer}::ng-deep .bizy-audio-player__download-button{--bizy-button-background-color: var(--bizy-audio-player-download-button-background-color);--bizy-button-color: var(--bizy-audio-player-download-button-color)}.bizy-audio-player__download-button__icon{height:1rem}\n"] }]
|
|
260
|
+
}], propDecorators: { id: [{
|
|
242
261
|
type: Input
|
|
243
262
|
}], mimeType: [{
|
|
244
263
|
type: Input
|