tunzo-player 1.0.9 → 1.0.11
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/core/player.d.ts +3 -0
- package/dist/core/player.js +8 -0
- package/package.json +4 -1
- package/src/core/player.ts +10 -0
package/dist/core/player.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { BehaviorSubject } from 'rxjs';
|
|
1
2
|
export declare class Player {
|
|
2
3
|
private static audio;
|
|
3
4
|
private static currentSong;
|
|
@@ -7,6 +8,7 @@ export declare class Player {
|
|
|
7
8
|
private static duration;
|
|
8
9
|
private static isShuffle;
|
|
9
10
|
private static queue;
|
|
11
|
+
static queue$: BehaviorSubject<any[]>;
|
|
10
12
|
private static playlist;
|
|
11
13
|
private static selectedQuality;
|
|
12
14
|
/** Initialize with playlist and quality */
|
|
@@ -23,6 +25,7 @@ export declare class Player {
|
|
|
23
25
|
static autoNext(): void;
|
|
24
26
|
static playRandom(): void;
|
|
25
27
|
static toggleShuffle(): void;
|
|
28
|
+
static getShuffleStatus(): boolean;
|
|
26
29
|
static addToQueue(song: any): void;
|
|
27
30
|
static removeFromQueue(index: number): void;
|
|
28
31
|
static reorderQueue(from: number, to: number): void;
|
package/dist/core/player.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Player = void 0;
|
|
4
|
+
const rxjs_1 = require("rxjs");
|
|
4
5
|
class Player {
|
|
5
6
|
/** Initialize with playlist and quality */
|
|
6
7
|
static initialize(playlist, quality = 3) {
|
|
@@ -93,17 +94,23 @@ class Player {
|
|
|
93
94
|
static toggleShuffle() {
|
|
94
95
|
this.isShuffle = !this.isShuffle;
|
|
95
96
|
}
|
|
97
|
+
static getShuffleStatus() {
|
|
98
|
+
return this.isShuffle;
|
|
99
|
+
}
|
|
96
100
|
static addToQueue(song) {
|
|
97
101
|
if (!this.queue.some(q => q.id === song.id)) {
|
|
98
102
|
this.queue.push(song);
|
|
103
|
+
this.queue$.next([...this.queue]);
|
|
99
104
|
}
|
|
100
105
|
}
|
|
101
106
|
static removeFromQueue(index) {
|
|
102
107
|
this.queue.splice(index, 1);
|
|
108
|
+
this.queue$.next([...this.queue]);
|
|
103
109
|
}
|
|
104
110
|
static reorderQueue(from, to) {
|
|
105
111
|
const item = this.queue.splice(from, 1)[0];
|
|
106
112
|
this.queue.splice(to, 0, item);
|
|
113
|
+
this.queue$.next([...this.queue]);
|
|
107
114
|
}
|
|
108
115
|
static getCurrentTime() {
|
|
109
116
|
return this.currentTime;
|
|
@@ -141,5 +148,6 @@ Player.currentTime = 0;
|
|
|
141
148
|
Player.duration = 0;
|
|
142
149
|
Player.isShuffle = true;
|
|
143
150
|
Player.queue = [];
|
|
151
|
+
Player.queue$ = new rxjs_1.BehaviorSubject([]);
|
|
144
152
|
Player.playlist = [];
|
|
145
153
|
Player.selectedQuality = 3;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tunzo-player",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.11",
|
|
4
4
|
"description": "A music playback service for Angular and Ionic apps with native audio control support.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -27,5 +27,8 @@
|
|
|
27
27
|
"license": "MIT",
|
|
28
28
|
"publishConfig": {
|
|
29
29
|
"access": "public"
|
|
30
|
+
},
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"rxjs": "^7.8.2"
|
|
30
33
|
}
|
|
31
34
|
}
|
package/src/core/player.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { BehaviorSubject } from 'rxjs';
|
|
2
|
+
|
|
1
3
|
export class Player {
|
|
2
4
|
private static audio = new Audio();
|
|
3
5
|
private static currentSong: any = null;
|
|
@@ -7,6 +9,7 @@ export class Player {
|
|
|
7
9
|
private static duration = 0;
|
|
8
10
|
private static isShuffle = true;
|
|
9
11
|
private static queue: any[] = [];
|
|
12
|
+
static queue$ = new BehaviorSubject<any[]>([]);
|
|
10
13
|
private static playlist: any[] = [];
|
|
11
14
|
private static selectedQuality = 3;
|
|
12
15
|
|
|
@@ -112,20 +115,27 @@ export class Player {
|
|
|
112
115
|
static toggleShuffle() {
|
|
113
116
|
this.isShuffle = !this.isShuffle;
|
|
114
117
|
}
|
|
118
|
+
|
|
119
|
+
static getShuffleStatus(): boolean {
|
|
120
|
+
return this.isShuffle;
|
|
121
|
+
}
|
|
115
122
|
|
|
116
123
|
static addToQueue(song: any) {
|
|
117
124
|
if (!this.queue.some(q => q.id === song.id)) {
|
|
118
125
|
this.queue.push(song);
|
|
126
|
+
this.queue$.next([...this.queue]);
|
|
119
127
|
}
|
|
120
128
|
}
|
|
121
129
|
|
|
122
130
|
static removeFromQueue(index: number) {
|
|
123
131
|
this.queue.splice(index, 1);
|
|
132
|
+
this.queue$.next([...this.queue]);
|
|
124
133
|
}
|
|
125
134
|
|
|
126
135
|
static reorderQueue(from: number, to: number) {
|
|
127
136
|
const item = this.queue.splice(from, 1)[0];
|
|
128
137
|
this.queue.splice(to, 0, item);
|
|
138
|
+
this.queue$.next([...this.queue]);
|
|
129
139
|
}
|
|
130
140
|
|
|
131
141
|
static getCurrentTime(): number {
|