capacitor-plugin-playlist 0.1.20 → 0.1.24
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/android/src/main/java/org/dwbn/plugins/playlist/PlaylistPlugin.kt +2 -2
- package/android/src/main/java/org/dwbn/plugins/playlist/RmxAudioPlayer.java +1 -1
- package/android/src/main/java/org/dwbn/plugins/playlist/manager/PlaylistManager.kt +18 -0
- package/dist/docs.json +8 -26
- package/dist/esm/Constants.js.map +1 -1
- package/dist/esm/RmxAudioPlayer.d.ts +4 -10
- package/dist/esm/RmxAudioPlayer.js +19 -22
- package/dist/esm/RmxAudioPlayer.js.map +1 -1
- package/dist/esm/definitions.d.ts +9 -8
- package/dist/esm/definitions.js +0 -1
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.js +1 -3
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/interfaces.js +0 -1
- package/dist/esm/plugin.js +1 -0
- package/dist/esm/plugin.js.map +1 -1
- package/dist/esm/utils.d.ts +1 -1
- package/dist/esm/utils.js.map +1 -1
- package/dist/esm/web.d.ts +3 -3
- package/dist/esm/web.js +32 -27
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +47 -44
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +48 -45
- package/dist/plugin.js.map +1 -1
- package/ios/Plugin/AVBidirectionalQueuePlayer.swift +18 -4
- package/ios/Plugin/AudioTrack.swift +0 -1
- package/ios/Plugin/DispatchQueue.swift +3 -3
- package/ios/Plugin/Plugin.swift +3 -3
- package/ios/Plugin/RmxAudioPlayer.swift +41 -42
- package/package.json +1 -1
- package/android/.gitignore +0 -1
- package/android/.npmignore +0 -1
|
@@ -107,8 +107,8 @@ class PlaylistPlugin : Plugin(), OnStatusReportListener {
|
|
|
107
107
|
|
|
108
108
|
@PluginMethod
|
|
109
109
|
fun removeItem(call: PluginCall) {
|
|
110
|
-
val trackIndex: Int = call.getInt("
|
|
111
|
-
val trackId: String = call.getString("
|
|
110
|
+
val trackIndex: Int = call.getInt("trackIndex", -1)!!
|
|
111
|
+
val trackId: String = call.getString("tracktrackId", "")!!
|
|
112
112
|
Log.i(TAG,"removeItem")
|
|
113
113
|
val item = audioPlayerImpl!!.playlistManager.removeItem(trackIndex, trackId)
|
|
114
114
|
|
|
@@ -226,7 +226,7 @@ public class RmxAudioPlayer implements PlaybackStatusListener<AudioTrack>,
|
|
|
226
226
|
|
|
227
227
|
AudioTrack currentItem = playlistManager.getCurrentItem();
|
|
228
228
|
JSONObject trackStatus = getPlayerStatus(currentItem);
|
|
229
|
-
Log.i("
|
|
229
|
+
Log.i("onPlaybackStateChanged", playbackState.toString() + ", " + trackStatus.toString() + ", " + currentItem);
|
|
230
230
|
|
|
231
231
|
switch (playbackState) {
|
|
232
232
|
case STOPPED:
|
|
@@ -56,6 +56,24 @@ class PlaylistManager(application: Application) :
|
|
|
56
56
|
return true
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
+
/*
|
|
60
|
+
* isNextAvailable, getCurrentItem, and next() are overridden because there is
|
|
61
|
+
* a glaring bug in playlist core where when an item completes, isNextAvailable and
|
|
62
|
+
* getCurrentItem return wildly contradictory things, resulting in endless repeat
|
|
63
|
+
* of the last item in the playlist.
|
|
64
|
+
*/
|
|
65
|
+
override val isNextAvailable: Boolean
|
|
66
|
+
get() {
|
|
67
|
+
if (itemCount == 1) {
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
val isAtEnd = currentPosition + 1 >= itemCount
|
|
71
|
+
val isConstrained = currentPosition + 1 in 0 until itemCount
|
|
72
|
+
return if (isAtEnd) {
|
|
73
|
+
loop
|
|
74
|
+
} else isConstrained
|
|
75
|
+
}
|
|
76
|
+
|
|
59
77
|
override operator fun next(): AudioTrack? {
|
|
60
78
|
if (isNextAvailable) {
|
|
61
79
|
val isAtEnd = currentPosition + 1 >= itemCount
|
package/dist/docs.json
CHANGED
|
@@ -587,34 +587,16 @@
|
|
|
587
587
|
"methods": [],
|
|
588
588
|
"properties": [
|
|
589
589
|
{
|
|
590
|
-
"name": "
|
|
590
|
+
"name": "id",
|
|
591
591
|
"tags": [],
|
|
592
592
|
"docs": "",
|
|
593
|
-
"complexTypes": [
|
|
594
|
-
"AudioTrackRemoval"
|
|
595
|
-
],
|
|
596
|
-
"type": "AudioTrackRemoval"
|
|
597
|
-
}
|
|
598
|
-
]
|
|
599
|
-
},
|
|
600
|
-
{
|
|
601
|
-
"name": "AudioTrackRemoval",
|
|
602
|
-
"slug": "audiotrackremoval",
|
|
603
|
-
"docs": "Encapsulates the fields you can pass to the plugin to remove a track.\nYou can either remove a track by its ID if you know it, or by index if you know it;\nIndex will be preferred if both index and ID are passed.",
|
|
604
|
-
"tags": [],
|
|
605
|
-
"methods": [],
|
|
606
|
-
"properties": [
|
|
607
|
-
{
|
|
608
|
-
"name": "trackId",
|
|
609
|
-
"tags": [],
|
|
610
|
-
"docs": "The track ID to remove",
|
|
611
593
|
"complexTypes": [],
|
|
612
594
|
"type": "string | undefined"
|
|
613
595
|
},
|
|
614
596
|
{
|
|
615
|
-
"name": "
|
|
597
|
+
"name": "index",
|
|
616
598
|
"tags": [],
|
|
617
|
-
"docs": "
|
|
599
|
+
"docs": "",
|
|
618
600
|
"complexTypes": [],
|
|
619
601
|
"type": "number | undefined"
|
|
620
602
|
}
|
|
@@ -633,7 +615,7 @@
|
|
|
633
615
|
"docs": "",
|
|
634
616
|
"complexTypes": [
|
|
635
617
|
"Array",
|
|
636
|
-
"
|
|
618
|
+
"RemoveItemOptions"
|
|
637
619
|
],
|
|
638
620
|
"type": "any"
|
|
639
621
|
}
|
|
@@ -674,7 +656,7 @@
|
|
|
674
656
|
"tags": [],
|
|
675
657
|
"docs": "",
|
|
676
658
|
"complexTypes": [],
|
|
677
|
-
"type": "number"
|
|
659
|
+
"type": "number | undefined"
|
|
678
660
|
}
|
|
679
661
|
]
|
|
680
662
|
},
|
|
@@ -697,7 +679,7 @@
|
|
|
697
679
|
"tags": [],
|
|
698
680
|
"docs": "",
|
|
699
681
|
"complexTypes": [],
|
|
700
|
-
"type": "number"
|
|
682
|
+
"type": "number | undefined"
|
|
701
683
|
}
|
|
702
684
|
]
|
|
703
685
|
},
|
|
@@ -720,7 +702,7 @@
|
|
|
720
702
|
"tags": [],
|
|
721
703
|
"docs": "",
|
|
722
704
|
"complexTypes": [],
|
|
723
|
-
"type": "number"
|
|
705
|
+
"type": "number | undefined"
|
|
724
706
|
}
|
|
725
707
|
]
|
|
726
708
|
},
|
|
@@ -743,7 +725,7 @@
|
|
|
743
725
|
"tags": [],
|
|
744
726
|
"docs": "",
|
|
745
727
|
"complexTypes": [],
|
|
746
|
-
"type": "number"
|
|
728
|
+
"type": "number | undefined"
|
|
747
729
|
}
|
|
748
730
|
]
|
|
749
731
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Constants.js","sourceRoot":"","sources":["../../src/Constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAN,IAAY,iBAMX;AAND,WAAY,iBAAiB;
|
|
1
|
+
{"version":3,"file":"Constants.js","sourceRoot":"","sources":["../../src/Constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAN,IAAY,iBAMX;AAND,WAAY,iBAAiB;IACzB,qFAAsB,CAAA;IACtB,6EAAkB,CAAA;IAClB,6EAAkB,CAAA;IAClB,2EAAiB,CAAA;IACjB,2FAAyB,CAAA;AAC7B,CAAC,EANW,iBAAiB,KAAjB,iBAAiB,QAM5B;AAAA,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,6BAA6B,GAAG;IACzC,mBAAmB;IACnB,SAAS;IACT,SAAS;IACT,kBAAkB;IAClB,sBAAsB;CACzB,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAN,IAAY,qBAuHX;AAvHD,WAAY,qBAAqB;IAC7B;;;OAGG;IACH,qFAAkB,CAAA;IAClB;;;OAGG;IACH,6FAAsB,CAAA;IAC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EAAE,EAAE,SAAS;IAEb,EAAE,EAAE,cAAc;IAClB,EAAE,EAAE,eAAe;IACnB,GAAG,EAAE,eAAe;IACpB,GAAG,EAAE,oBAAoB;IACzB,GAAG,EAAE,aAAa;IAClB,GAAG,EAAE,eAAe;IACpB,GAAG,EAAE,kBAAkB;IAEvB,GAAG,EAAE,wBAAwB;CAChC,CAAC"}
|
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
import { RmxAudioStatusMessage } from './Constants';
|
|
2
|
-
import { AudioPlayerEventHandler, AudioPlayerEventHandlers, AudioPlayerOptions, AudioTrack, AudioTrackRemoval, OnStatusCallback,
|
|
3
|
-
/**
|
|
4
|
-
* AudioPlayer class implementation. A singleton of this class is exported for use by Cordova,
|
|
5
|
-
* but nothing stops you from creating another instance. Keep in mind that the native players
|
|
6
|
-
* are in fact singletons, so the only thing the separate instance gives you would be
|
|
7
|
-
* separate onStatus callback streams.
|
|
8
|
-
*/
|
|
2
|
+
import { AudioPlayerEventHandler, AudioPlayerEventHandlers, AudioPlayerOptions, AudioTrack, AudioTrackRemoval, OnStatusCallback, OnStatusCallbackUpdateData, OnStatusErrorCallbackData, OnStatusTrackChangedData, PlaylistItemOptions } from './interfaces';
|
|
9
3
|
export declare class RmxAudioPlayer {
|
|
10
4
|
handlers: AudioPlayerEventHandlers;
|
|
11
5
|
options: AudioPlayerOptions;
|
|
@@ -66,8 +60,8 @@ export declare class RmxAudioPlayer {
|
|
|
66
60
|
/**
|
|
67
61
|
* Returns a promise that resolves when the plugin is ready.
|
|
68
62
|
*/
|
|
69
|
-
ready: () => Promise<
|
|
70
|
-
initialize: () => Promise<
|
|
63
|
+
ready: () => Promise<void>;
|
|
64
|
+
initialize: () => Promise<void>;
|
|
71
65
|
/**
|
|
72
66
|
* Sets the player options. This can be called at any time and is not required before playback can be initiated.
|
|
73
67
|
*/
|
|
@@ -175,7 +169,7 @@ export declare class RmxAudioPlayer {
|
|
|
175
169
|
* @param eventName Name of event to subscribe to.
|
|
176
170
|
* @param callback The callback function to receive the event data
|
|
177
171
|
*/
|
|
178
|
-
on(eventName:
|
|
172
|
+
on(eventName: 'status', callback: OnStatusCallback): void;
|
|
179
173
|
/**
|
|
180
174
|
* Remove an event handler from the plugin
|
|
181
175
|
* @param eventName The name of the event whose subscription is to be removed
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { RmxAudioStatusMessage, RmxAudioStatusMessageDescriptions
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { RmxAudioStatusMessage, RmxAudioStatusMessageDescriptions } from './Constants';
|
|
2
|
+
import { Playlist } from './plugin';
|
|
3
|
+
import { validateTrack, validateTracks } from './utils';
|
|
4
4
|
/*!
|
|
5
5
|
* Module dependencies.
|
|
6
6
|
*/
|
|
7
|
-
const log = console;
|
|
8
7
|
const itemStatusChangeTypes = [
|
|
9
8
|
RmxAudioStatusMessage.RMXSTATUS_PLAYBACK_POSITION,
|
|
10
9
|
RmxAudioStatusMessage.RMXSTATUS_DURATION,
|
|
@@ -16,12 +15,6 @@ const itemStatusChangeTypes = [
|
|
|
16
15
|
RmxAudioStatusMessage.RMXSTATUS_COMPLETED,
|
|
17
16
|
RmxAudioStatusMessage.RMXSTATUS_ERROR,
|
|
18
17
|
];
|
|
19
|
-
/**
|
|
20
|
-
* AudioPlayer class implementation. A singleton of this class is exported for use by Cordova,
|
|
21
|
-
* but nothing stops you from creating another instance. Keep in mind that the native players
|
|
22
|
-
* are in fact singletons, so the only thing the separate instance gives you would be
|
|
23
|
-
* separate onStatus callback streams.
|
|
24
|
-
*/
|
|
25
18
|
export class RmxAudioPlayer {
|
|
26
19
|
/**
|
|
27
20
|
* Creates a new RmxAudioPlayer instance.
|
|
@@ -30,6 +23,10 @@ export class RmxAudioPlayer {
|
|
|
30
23
|
this.handlers = {};
|
|
31
24
|
this.options = { verbose: false, resetStreamOnPause: true };
|
|
32
25
|
this._inititialized = false;
|
|
26
|
+
this._readyResolve = () => {
|
|
27
|
+
};
|
|
28
|
+
this._readyReject = () => {
|
|
29
|
+
};
|
|
33
30
|
this._currentState = 'unknown';
|
|
34
31
|
this._hasError = false;
|
|
35
32
|
this._hasLoaded = false;
|
|
@@ -43,7 +40,7 @@ export class RmxAudioPlayer {
|
|
|
43
40
|
this.ready = () => {
|
|
44
41
|
return this._initPromise;
|
|
45
42
|
};
|
|
46
|
-
this.initialize = () => {
|
|
43
|
+
this.initialize = async () => {
|
|
47
44
|
Playlist.addListener('status', (data) => {
|
|
48
45
|
if (data.action === 'status') {
|
|
49
46
|
this.onStatus(data.status.trackId, data.status.msgType, data.status.value);
|
|
@@ -52,16 +49,16 @@ export class RmxAudioPlayer {
|
|
|
52
49
|
console.warn('Unknown audio player onStatus message:', data);
|
|
53
50
|
}
|
|
54
51
|
});
|
|
55
|
-
|
|
56
|
-
.
|
|
52
|
+
try {
|
|
53
|
+
await Playlist.initialize();
|
|
57
54
|
this._inititialized = true;
|
|
58
|
-
this._readyResolve(
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
const message = '
|
|
55
|
+
this._readyResolve();
|
|
56
|
+
}
|
|
57
|
+
catch (args) {
|
|
58
|
+
const message = 'Capacitor RMXAUDIOPLAYER: Error initializing:';
|
|
62
59
|
console.warn(message, args);
|
|
63
|
-
this._readyReject(
|
|
64
|
-
}
|
|
60
|
+
this._readyReject();
|
|
61
|
+
}
|
|
65
62
|
return this._initPromise;
|
|
66
63
|
};
|
|
67
64
|
/**
|
|
@@ -110,14 +107,14 @@ export class RmxAudioPlayer {
|
|
|
110
107
|
if (!removeItem.trackId && !removeItem.trackIndex) {
|
|
111
108
|
new Error('Track removal spec is invalid');
|
|
112
109
|
}
|
|
113
|
-
return Playlist.removeItem({
|
|
110
|
+
return Playlist.removeItem({ id: removeItem.trackId, index: removeItem.trackIndex });
|
|
114
111
|
};
|
|
115
112
|
/**
|
|
116
113
|
* Removes all given tracks from the playlist; these can be specified either by trackId or trackIndex. If the removed items
|
|
117
114
|
* include the currently playing item, the next available item will automatically begin playing.
|
|
118
115
|
*/
|
|
119
116
|
this.removeItems = (items) => {
|
|
120
|
-
return Playlist.removeItems({ items });
|
|
117
|
+
return Playlist.removeItems({ items: items });
|
|
121
118
|
};
|
|
122
119
|
/**
|
|
123
120
|
* Clear the entire playlist. This will result in the STOPPED event being raised.
|
|
@@ -280,7 +277,7 @@ export class RmxAudioPlayer {
|
|
|
280
277
|
var _a;
|
|
281
278
|
const status = { type: type, trackId: trackId, value: value };
|
|
282
279
|
if (this.options.verbose) {
|
|
283
|
-
|
|
280
|
+
console.debug(`RmxAudioPlayer.onStatus: ${RmxAudioStatusMessageDescriptions[type]}(${type}) [${trackId}]: `, value);
|
|
284
281
|
}
|
|
285
282
|
if (status.type === RmxAudioStatusMessage.RMXSTATUS_TRACK_CHANGED) {
|
|
286
283
|
this._hasError = false;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RmxAudioPlayer.js","sourceRoot":"","sources":["../../src/RmxAudioPlayer.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"RmxAudioPlayer.js","sourceRoot":"","sources":["../../src/RmxAudioPlayer.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,qBAAqB,EACrB,iCAAiC,EACpC,MAAM,aAAa,CAAC;AAiBrB,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAGxD;;GAEG;AAEH,MAAM,qBAAqB,GAAG;IAC1B,qBAAqB,CAAC,2BAA2B;IACjD,qBAAqB,CAAC,kBAAkB;IACxC,qBAAqB,CAAC,mBAAmB;IACzC,qBAAqB,CAAC,iBAAiB;IACvC,qBAAqB,CAAC,iBAAiB;IACvC,qBAAqB,CAAC,gBAAgB;IACtC,qBAAqB,CAAC,eAAe;IACrC,qBAAqB,CAAC,mBAAmB;IACzC,qBAAqB,CAAC,eAAe;CACxC,CAAC;AAEF,MAAM,OAA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le } from '@capacitor/core';
|
|
2
|
+
import { AudioPlayerOptions, AudioTrack, PlaylistItemOptions, PlaylistStatusChangeCallback } from './interfaces';
|
|
3
3
|
export interface PlaylistPlugin {
|
|
4
4
|
/**
|
|
5
5
|
* Listen for screen reader state change (on/off)
|
|
@@ -38,29 +38,30 @@ export interface AddAllItemOptions {
|
|
|
38
38
|
items: Array<AudioTrack>;
|
|
39
39
|
}
|
|
40
40
|
export interface RemoveItemOptions {
|
|
41
|
-
|
|
41
|
+
id?: string;
|
|
42
|
+
index?: number;
|
|
42
43
|
}
|
|
43
44
|
export interface RemoveItemsOptions {
|
|
44
|
-
items: Array<
|
|
45
|
+
items: Array<RemoveItemOptions>;
|
|
45
46
|
}
|
|
46
47
|
export interface SeekToOptions {
|
|
47
48
|
position: number;
|
|
48
49
|
}
|
|
49
50
|
export interface PlayByIndexOptions {
|
|
50
51
|
index: number;
|
|
51
|
-
position
|
|
52
|
+
position?: number;
|
|
52
53
|
}
|
|
53
54
|
export interface PlayByIdOptions {
|
|
54
55
|
id: string;
|
|
55
|
-
position
|
|
56
|
+
position?: number;
|
|
56
57
|
}
|
|
57
58
|
export interface SelectByIndexOptions {
|
|
58
59
|
index: number;
|
|
59
|
-
position
|
|
60
|
+
position?: number;
|
|
60
61
|
}
|
|
61
62
|
export interface SelectByIdOptions {
|
|
62
63
|
id: string;
|
|
63
|
-
position
|
|
64
|
+
position?: number;
|
|
64
65
|
}
|
|
65
66
|
export interface SetPlaybackVolumeOptions {
|
|
66
67
|
volume: number;
|
package/dist/esm/definitions.js
CHANGED
package/dist/esm/index.d.ts
CHANGED
package/dist/esm/index.js
CHANGED
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAEA,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC;AACjC,cAAc,UAAU,CAAC"}
|
package/dist/esm/interfaces.js
CHANGED
package/dist/esm/plugin.js
CHANGED
package/dist/esm/plugin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../../src/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../../src/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAC,MAAM,iBAAiB,CAAC;AAI/C,2CAA2C;AAC3C,IAAI,mBAAmC,CAAC;AACxC,MAAM,QAAQ,GAAG,cAAc,CAAiB,UAAU,EAAE;IACxD,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE;QAChC,IAAI,CAAC,mBAAmB,EAAE;YACtB,mBAAmB,GAAG,IAAI,CAAC,CAAC,WAAW,EAAE,CAAC;SAC7C;QACD,OAAO,mBAAmB,CAAC;IAC/B,CAAC,CAAC;CACL,CAAC,CAAC;AACH,OAAO,EAAC,QAAQ,EAAC,CAAC"}
|
package/dist/esm/utils.d.ts
CHANGED
package/dist/esm/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,KAAmB,EAAE,EAAE;IAClD,IAAI,CAAC,KAAK,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,KAAmB,EAAE,EAAE;IAClD,IAAI,CAAC,KAAK,IAAI,CAAC,KA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AAK,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,GAAG,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IAC1D,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AAChB,CAAC,CAAC"}
|
package/dist/esm/web.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { WebPlugin } from '@capacitor/core';
|
|
2
|
-
import { AddAllItemOptions, AddItemOptions, PlayByIdOptions, PlayByIndexOptions, PlaylistOptions, PlaylistPlugin, RemoveItemOptions, RemoveItemsOptions, SeekToOptions, SelectByIdOptions, SelectByIndexOptions, SetLoopOptions,
|
|
3
|
-
import {
|
|
2
|
+
import { AddAllItemOptions, AddItemOptions, PlayByIdOptions, PlayByIndexOptions, PlaylistOptions, PlaylistPlugin, RemoveItemOptions, RemoveItemsOptions, SeekToOptions, SelectByIdOptions, SelectByIndexOptions, SetLoopOptions, SetPlaybackRateOptions, SetPlaybackVolumeOptions } from './definitions';
|
|
3
|
+
import { AudioPlayerOptions, AudioTrack } from './interfaces';
|
|
4
4
|
export declare class PlaylistWeb extends WebPlugin implements PlaylistPlugin {
|
|
5
5
|
protected audio: HTMLVideoElement | undefined;
|
|
6
6
|
protected playlistItems: AudioTrack[];
|
|
@@ -37,7 +37,7 @@ export declare class PlaylistWeb extends WebPlugin implements PlaylistPlugin {
|
|
|
37
37
|
isStream: boolean;
|
|
38
38
|
currentIndex: number;
|
|
39
39
|
status: string;
|
|
40
|
-
currentPosition: number
|
|
40
|
+
currentPosition: number;
|
|
41
41
|
};
|
|
42
42
|
protected setCurrent(item: AudioTrack, position?: number): Promise<void>;
|
|
43
43
|
protected log(message?: any, ...optionalParams: any[]): void;
|
package/dist/esm/web.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { WebPlugin } from '@capacitor/core';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { RmxAudioStatusMessage } from './Constants';
|
|
3
|
+
import { validateTrack, validateTracks } from './utils';
|
|
4
4
|
export class PlaylistWeb extends WebPlugin {
|
|
5
5
|
constructor() {
|
|
6
6
|
super(...arguments);
|
|
@@ -8,7 +8,7 @@ export class PlaylistWeb extends WebPlugin {
|
|
|
8
8
|
this.loop = false;
|
|
9
9
|
this.options = {};
|
|
10
10
|
this.currentTrack = null;
|
|
11
|
-
this.lastState =
|
|
11
|
+
this.lastState = 'stopped';
|
|
12
12
|
this.hlsLoaded = false;
|
|
13
13
|
}
|
|
14
14
|
addAllItems(options) {
|
|
@@ -39,7 +39,6 @@ export class PlaylistWeb extends WebPlugin {
|
|
|
39
39
|
return (_a = this.audio) === null || _a === void 0 ? void 0 : _a.play();
|
|
40
40
|
}
|
|
41
41
|
playTrackById(options) {
|
|
42
|
-
console.log("da");
|
|
43
42
|
this.playlistItems.forEach(async (item) => {
|
|
44
43
|
if (item.trackId === options.id) {
|
|
45
44
|
await this.setCurrent(item);
|
|
@@ -64,10 +63,10 @@ export class PlaylistWeb extends WebPlugin {
|
|
|
64
63
|
}
|
|
65
64
|
removeItem(options) {
|
|
66
65
|
this.playlistItems.forEach((item, index) => {
|
|
67
|
-
if (options.
|
|
66
|
+
if (options.index && options.index === index) {
|
|
68
67
|
this.playlistItems.splice(index, 1);
|
|
69
68
|
}
|
|
70
|
-
else if (options.
|
|
69
|
+
else if (options.id && options.id === item.trackId) {
|
|
71
70
|
this.playlistItems.splice(index, 1);
|
|
72
71
|
}
|
|
73
72
|
});
|
|
@@ -75,7 +74,7 @@ export class PlaylistWeb extends WebPlugin {
|
|
|
75
74
|
}
|
|
76
75
|
removeItems(options) {
|
|
77
76
|
options.items.forEach((item) => {
|
|
78
|
-
this.removeItem(
|
|
77
|
+
this.removeItem(item);
|
|
79
78
|
});
|
|
80
79
|
return Promise.resolve();
|
|
81
80
|
}
|
|
@@ -186,7 +185,7 @@ export class PlaylistWeb extends WebPlugin {
|
|
|
186
185
|
const canPlayListener = async () => {
|
|
187
186
|
var _a;
|
|
188
187
|
this.notifyListeners('status', {
|
|
189
|
-
action:
|
|
188
|
+
action: 'status',
|
|
190
189
|
status: {
|
|
191
190
|
msgType: RmxAudioStatusMessage.RMXSTATUS_CANPLAY,
|
|
192
191
|
trackId: this.getCurrentTrackId(),
|
|
@@ -202,7 +201,7 @@ export class PlaylistWeb extends WebPlugin {
|
|
|
202
201
|
this.audio.addEventListener('canplay', canPlayListener);
|
|
203
202
|
this.audio.addEventListener('playing', () => {
|
|
204
203
|
this.notifyListeners('status', {
|
|
205
|
-
action:
|
|
204
|
+
action: 'status',
|
|
206
205
|
status: {
|
|
207
206
|
msgType: RmxAudioStatusMessage.RMXSTATUS_PLAYING,
|
|
208
207
|
trackId: this.getCurrentTrackId(),
|
|
@@ -212,7 +211,7 @@ export class PlaylistWeb extends WebPlugin {
|
|
|
212
211
|
});
|
|
213
212
|
this.audio.addEventListener('pause', () => {
|
|
214
213
|
this.notifyListeners('status', {
|
|
215
|
-
action:
|
|
214
|
+
action: 'status',
|
|
216
215
|
status: {
|
|
217
216
|
msgType: RmxAudioStatusMessage.RMXSTATUS_PAUSE,
|
|
218
217
|
trackId: this.getCurrentTrackId(),
|
|
@@ -222,7 +221,7 @@ export class PlaylistWeb extends WebPlugin {
|
|
|
222
221
|
});
|
|
223
222
|
this.audio.addEventListener('error', () => {
|
|
224
223
|
this.notifyListeners('status', {
|
|
225
|
-
action:
|
|
224
|
+
action: 'status',
|
|
226
225
|
status: {
|
|
227
226
|
msgType: RmxAudioStatusMessage.RMXSTATUS_ERROR,
|
|
228
227
|
trackId: this.getCurrentTrackId(),
|
|
@@ -232,7 +231,7 @@ export class PlaylistWeb extends WebPlugin {
|
|
|
232
231
|
});
|
|
233
232
|
this.audio.addEventListener('ended', () => {
|
|
234
233
|
this.notifyListeners('status', {
|
|
235
|
-
action:
|
|
234
|
+
action: 'status',
|
|
236
235
|
status: {
|
|
237
236
|
msgType: RmxAudioStatusMessage.RMXSTATUS_STOPPED,
|
|
238
237
|
trackId: this.getCurrentTrackId(),
|
|
@@ -240,15 +239,21 @@ export class PlaylistWeb extends WebPlugin {
|
|
|
240
239
|
}
|
|
241
240
|
});
|
|
242
241
|
});
|
|
242
|
+
let lastTrackId, lastPosition;
|
|
243
243
|
this.audio.addEventListener('timeupdate', () => {
|
|
244
|
-
this.
|
|
245
|
-
|
|
246
|
-
status
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
244
|
+
const status = this.getCurrentTrackStatus(this.lastState);
|
|
245
|
+
if (lastTrackId !== this.getCurrentTrackId() || lastPosition !== status.currentPosition) {
|
|
246
|
+
this.notifyListeners('status', {
|
|
247
|
+
action: 'status',
|
|
248
|
+
status: {
|
|
249
|
+
msgType: RmxAudioStatusMessage.RMXSTATUS_PLAYBACK_POSITION,
|
|
250
|
+
trackId: this.getCurrentTrackId(),
|
|
251
|
+
value: status,
|
|
252
|
+
}
|
|
253
|
+
});
|
|
254
|
+
lastTrackId = this.getCurrentTrackId();
|
|
255
|
+
lastPosition = status.currentPosition;
|
|
256
|
+
}
|
|
252
257
|
});
|
|
253
258
|
}
|
|
254
259
|
}
|
|
@@ -256,7 +261,7 @@ export class PlaylistWeb extends WebPlugin {
|
|
|
256
261
|
if (this.currentTrack) {
|
|
257
262
|
return this.currentTrack.trackId;
|
|
258
263
|
}
|
|
259
|
-
return
|
|
264
|
+
return 'INVALID';
|
|
260
265
|
}
|
|
261
266
|
getCurrentIndex() {
|
|
262
267
|
if (this.currentTrack) {
|
|
@@ -276,7 +281,7 @@ export class PlaylistWeb extends WebPlugin {
|
|
|
276
281
|
isStream: !!((_a = this.currentTrack) === null || _a === void 0 ? void 0 : _a.isStream),
|
|
277
282
|
currentIndex: this.getCurrentIndex(),
|
|
278
283
|
status: currentState,
|
|
279
|
-
currentPosition: (_b = this.audio) === null || _b === void 0 ? void 0 : _b.currentTime,
|
|
284
|
+
currentPosition: ((_b = this.audio) === null || _b === void 0 ? void 0 : _b.currentTime) || 0,
|
|
280
285
|
};
|
|
281
286
|
}
|
|
282
287
|
async setCurrent(item, position) {
|
|
@@ -284,7 +289,7 @@ export class PlaylistWeb extends WebPlugin {
|
|
|
284
289
|
if (this.audio) {
|
|
285
290
|
wasPlaying = !this.audio.paused;
|
|
286
291
|
this.audio.pause();
|
|
287
|
-
this.audio.src =
|
|
292
|
+
this.audio.src = '';
|
|
288
293
|
this.audio.removeAttribute('src');
|
|
289
294
|
this.audio.load();
|
|
290
295
|
}
|
|
@@ -312,8 +317,8 @@ export class PlaylistWeb extends WebPlugin {
|
|
|
312
317
|
this.play();
|
|
313
318
|
});
|
|
314
319
|
}
|
|
315
|
-
this.notifyListeners(
|
|
316
|
-
action:
|
|
320
|
+
this.notifyListeners('status', {
|
|
321
|
+
action: 'status',
|
|
317
322
|
status: {
|
|
318
323
|
msgType: RmxAudioStatusMessage.RMXSTATUS_TRACK_CHANGED,
|
|
319
324
|
trackId: this.getCurrentTrackId(),
|
|
@@ -335,11 +340,11 @@ export class PlaylistWeb extends WebPlugin {
|
|
|
335
340
|
return new Promise((resolve, reject) => {
|
|
336
341
|
var script = document.createElement('script');
|
|
337
342
|
script.type = 'text/javascript';
|
|
338
|
-
script.src = 'https://cdn.jsdelivr.net/npm/hls.js@
|
|
343
|
+
script.src = 'https://cdn.jsdelivr.net/npm/hls.js@1.1.1';
|
|
339
344
|
document.getElementsByTagName('head')[0].appendChild(script);
|
|
340
345
|
script.onload = () => {
|
|
341
346
|
this.hlsLoaded = true;
|
|
342
|
-
resolve();
|
|
347
|
+
resolve(void 0);
|
|
343
348
|
};
|
|
344
349
|
script.onerror = () => {
|
|
345
350
|
reject();
|