capacitor-plugin-playlist 0.1.18 → 0.1.22
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 +4 -8
- package/android/src/main/java/org/dwbn/plugins/playlist/RmxAudioPlayer.java +397 -385
- package/android/src/main/java/org/dwbn/plugins/playlist/manager/PlaylistManager.kt +17 -12
- package/android/src/main/java/org/dwbn/plugins/playlist/notification/PlaylistNotificationProvider.kt +5 -1
- package/android/src/main/java/org/dwbn/plugins/playlist/service/MediaService.kt +1 -2
- package/dist/docs.json +5 -23
- 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 +5 -4
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -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/RmxAudioPlayer.swift +77 -108
- package/package.json +1 -1
- package/android/.gitignore +0 -1
- package/android/.npmignore +0 -1
- package/ios/.DS_Store +0 -0
|
@@ -19,14 +19,13 @@ import java.util.*
|
|
|
19
19
|
* A PlaylistManager that extends the [ListPlaylistManager] for use with the
|
|
20
20
|
* [MediaService] which extends [com.devbrackets.android.playlistcore.service.BasePlaylistService].
|
|
21
21
|
*/
|
|
22
|
-
class
|
|
22
|
+
class PlaylistManager(application: Application) :
|
|
23
|
+
ListPlaylistManager<AudioTrack>(application, MediaService::class.java), OnErrorListener {
|
|
23
24
|
private val audioTracks: MutableList<AudioTrack> = ArrayList()
|
|
24
25
|
private var volumeLeft = 1.0f
|
|
25
26
|
private var volumeRight = 1.0f
|
|
26
27
|
private var playbackSpeed = 1.0f
|
|
27
28
|
var loop = false
|
|
28
|
-
get
|
|
29
|
-
set
|
|
30
29
|
var isShouldStopPlaylist = false
|
|
31
30
|
var currentErrorTrack: AudioTrack? = null
|
|
32
31
|
|
|
@@ -35,7 +34,8 @@ class PlaylistManager(application: Application) : ListPlaylistManager<AudioTrac
|
|
|
35
34
|
var options: Options
|
|
36
35
|
private var mediaControlsListener = WeakReference<MediaControlsListener?>(null)
|
|
37
36
|
private var errorListener = WeakReference<OnErrorListener?>(null)
|
|
38
|
-
private var currentMediaPlayer: WeakReference<MediaPlayerApi<AudioTrack>?>? =
|
|
37
|
+
private var currentMediaPlayer: WeakReference<MediaPlayerApi<AudioTrack>?>? =
|
|
38
|
+
WeakReference(null)
|
|
39
39
|
|
|
40
40
|
fun setOnErrorListener(listener: OnErrorListener?) {
|
|
41
41
|
errorListener = WeakReference(listener)
|
|
@@ -64,6 +64,9 @@ class PlaylistManager(application: Application) : ListPlaylistManager<AudioTrac
|
|
|
64
64
|
*/
|
|
65
65
|
override val isNextAvailable: Boolean
|
|
66
66
|
get() {
|
|
67
|
+
if (itemCount == 1) {
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
67
70
|
val isAtEnd = currentPosition + 1 >= itemCount
|
|
68
71
|
val isConstrained = currentPosition + 1 in 0 until itemCount
|
|
69
72
|
return if (isAtEnd) {
|
|
@@ -74,10 +77,9 @@ class PlaylistManager(application: Application) : ListPlaylistManager<AudioTrac
|
|
|
74
77
|
override operator fun next(): AudioTrack? {
|
|
75
78
|
if (isNextAvailable) {
|
|
76
79
|
val isAtEnd = currentPosition + 1 >= itemCount
|
|
77
|
-
if(isAtEnd && loop) {
|
|
80
|
+
if (isAtEnd && loop) {
|
|
78
81
|
currentPosition = 0
|
|
79
|
-
}
|
|
80
|
-
else {
|
|
82
|
+
} else {
|
|
81
83
|
currentPosition = (currentPosition + 1).coerceAtMost(itemCount)
|
|
82
84
|
}
|
|
83
85
|
} else {
|
|
@@ -139,7 +141,7 @@ class PlaylistManager(application: Application) : ListPlaylistManager<AudioTrac
|
|
|
139
141
|
val countBefore = audioTracks.size;
|
|
140
142
|
audioTracks.add(item)
|
|
141
143
|
items = audioTracks
|
|
142
|
-
if(countBefore == 0) {
|
|
144
|
+
if (countBefore == 0) {
|
|
143
145
|
currentPosition = 0
|
|
144
146
|
beginPlayback(1, true)
|
|
145
147
|
}
|
|
@@ -148,7 +150,8 @@ class PlaylistManager(application: Application) : ListPlaylistManager<AudioTrac
|
|
|
148
150
|
fun addAllItems(its: List<AudioTrack>?) {
|
|
149
151
|
val currentItem = currentItem // may be null
|
|
150
152
|
audioTracks.addAll(its!!)
|
|
151
|
-
items =
|
|
153
|
+
items =
|
|
154
|
+
audioTracks // not *strictly* needed since they share the reference, but for good measure..
|
|
152
155
|
currentPosition = audioTracks.indexOf(currentItem)
|
|
153
156
|
}
|
|
154
157
|
|
|
@@ -158,7 +161,6 @@ class PlaylistManager(application: Application) : ListPlaylistManager<AudioTrac
|
|
|
158
161
|
playlistHandler!!.pause(true)
|
|
159
162
|
}
|
|
160
163
|
var currentPosition = currentPosition
|
|
161
|
-
val currentItem = currentItem // may be null
|
|
162
164
|
var foundItem: AudioTrack? = null
|
|
163
165
|
var removingCurrent = false
|
|
164
166
|
|
|
@@ -219,7 +221,7 @@ class PlaylistManager(application: Application) : ListPlaylistManager<AudioTrac
|
|
|
219
221
|
var resolvedPosition = -1
|
|
220
222
|
if (trackIndex >= 0 && trackIndex < audioTracks.size) {
|
|
221
223
|
resolvedPosition = trackIndex
|
|
222
|
-
} else if (
|
|
224
|
+
} else if ("" != trackId) {
|
|
223
225
|
val itemPos = getPositionForItem(trackId.hashCode().toLong())
|
|
224
226
|
if (itemPos != INVALID_POSITION) {
|
|
225
227
|
resolvedPosition = itemPos
|
|
@@ -236,7 +238,10 @@ class PlaylistManager(application: Application) : ListPlaylistManager<AudioTrac
|
|
|
236
238
|
return volumeRight
|
|
237
239
|
}
|
|
238
240
|
|
|
239
|
-
fun setVolume(
|
|
241
|
+
fun setVolume(
|
|
242
|
+
@FloatRange(from = 0.0, to = 1.0) left: Float,
|
|
243
|
+
@FloatRange(from = 0.0, to = 1.0) right: Float
|
|
244
|
+
) {
|
|
240
245
|
volumeLeft = left
|
|
241
246
|
volumeRight = right
|
|
242
247
|
if (currentMediaPlayer != null && currentMediaPlayer!!.get() != null) {
|
package/android/src/main/java/org/dwbn/plugins/playlist/notification/PlaylistNotificationProvider.kt
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
package org.dwbn.plugins.playlist.notification
|
|
2
2
|
|
|
3
|
+
import android.annotation.SuppressLint
|
|
3
4
|
import android.app.PendingIntent
|
|
5
|
+
import android.app.PendingIntent.FLAG_UPDATE_CURRENT
|
|
4
6
|
import android.content.Context
|
|
5
7
|
import android.content.Intent
|
|
6
8
|
import com.devbrackets.android.playlistcore.components.notification.DefaultPlaylistNotificationProvider
|
|
7
9
|
|
|
8
10
|
class PlaylistNotificationProvider(context: Context?) : DefaultPlaylistNotificationProvider(context!!) {
|
|
9
11
|
override val clickPendingIntent: PendingIntent?
|
|
12
|
+
@SuppressLint("UnspecifiedImmutableFlag")
|
|
10
13
|
get() {
|
|
11
14
|
val context = context
|
|
12
15
|
val pkgName = context.packageName
|
|
@@ -16,6 +19,7 @@ class PlaylistNotificationProvider(context: Context?) : DefaultPlaylistNotificat
|
|
|
16
19
|
intent!!.addFlags(
|
|
17
20
|
Intent.FLAG_ACTIVITY_REORDER_TO_FRONT or Intent.FLAG_ACTIVITY_SINGLE_TOP)
|
|
18
21
|
return PendingIntent.getActivity(this.context,
|
|
19
|
-
0, intent,
|
|
22
|
+
0, intent, FLAG_UPDATE_CURRENT
|
|
23
|
+
)
|
|
20
24
|
}
|
|
21
25
|
}
|
|
@@ -4,7 +4,6 @@ import com.devbrackets.android.playlistcore.components.playlisthandler.PlaylistH
|
|
|
4
4
|
import com.devbrackets.android.playlistcore.service.BasePlaylistService
|
|
5
5
|
import org.dwbn.plugins.playlist.App
|
|
6
6
|
import org.dwbn.plugins.playlist.data.AudioTrack
|
|
7
|
-
import org.dwbn.plugins.playlist.manager.Options
|
|
8
7
|
import org.dwbn.plugins.playlist.manager.PlaylistManager
|
|
9
8
|
import org.dwbn.plugins.playlist.playlist.AudioApi
|
|
10
9
|
import org.dwbn.plugins.playlist.playlist.AudioPlaylistHandler
|
|
@@ -41,7 +40,7 @@ class MediaService : BasePlaylistService<AudioTrack, PlaylistManager>() {
|
|
|
41
40
|
override fun onImageUpdated() {
|
|
42
41
|
playlistHandler.updateMediaControls()
|
|
43
42
|
}
|
|
44
|
-
},
|
|
43
|
+
}, playlistManager.options)
|
|
45
44
|
|
|
46
45
|
return AudioPlaylistHandler.Builder(
|
|
47
46
|
applicationContext,
|
package/dist/docs.json
CHANGED
|
@@ -585,38 +585,20 @@
|
|
|
585
585
|
"docs": "",
|
|
586
586
|
"tags": [],
|
|
587
587
|
"methods": [],
|
|
588
|
-
"properties": [
|
|
589
|
-
{
|
|
590
|
-
"name": "item",
|
|
591
|
-
"tags": [],
|
|
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
588
|
"properties": [
|
|
607
589
|
{
|
|
608
590
|
"name": "trackId",
|
|
609
591
|
"tags": [],
|
|
610
|
-
"docs": "
|
|
592
|
+
"docs": "",
|
|
611
593
|
"complexTypes": [],
|
|
612
|
-
"type": "string
|
|
594
|
+
"type": "string"
|
|
613
595
|
},
|
|
614
596
|
{
|
|
615
597
|
"name": "trackIndex",
|
|
616
598
|
"tags": [],
|
|
617
|
-
"docs": "
|
|
599
|
+
"docs": "",
|
|
618
600
|
"complexTypes": [],
|
|
619
|
-
"type": "number
|
|
601
|
+
"type": "number"
|
|
620
602
|
}
|
|
621
603
|
]
|
|
622
604
|
},
|
|
@@ -633,7 +615,7 @@
|
|
|
633
615
|
"docs": "",
|
|
634
616
|
"complexTypes": [
|
|
635
617
|
"Array",
|
|
636
|
-
"
|
|
618
|
+
"RemoveItemOptions"
|
|
637
619
|
],
|
|
638
620
|
"type": "any"
|
|
639
621
|
}
|
|
@@ -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,CAA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AAS;IACb,EAAE,EAAE,QAAQ;IACZ,EAAE,EAAE,2BAA2B;IAC/B,EAAE,EAAE,QAAQ;IACZ,EAAE,EAAE,oBAAoB;IACxB,EAAE,EAAE,kBAAkB;IACtB,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({ trackId: removeItem.trackId, trackIndex: 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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AAC,CAAC;aACrB;SACJ;QAED,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { PluginListenerHandle } 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,10 +38,11 @@ export interface AddAllItemOptions {
|
|
|
38
38
|
items: Array<AudioTrack>;
|
|
39
39
|
}
|
|
40
40
|
export interface RemoveItemOptions {
|
|
41
|
-
|
|
41
|
+
trackId: string;
|
|
42
|
+
trackIndex: 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;
|
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":"AAEA,cAAc,aAAa,
|
|
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/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,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;QACjC,OAAO,EAAE,CAAC;KACb;IACD,OAAO,KAAK,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAiB,CAAC,CAAC,8BAA8B;AACpG,CAAC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,KAAiB,EAAE,EAAE;IAC/C,IAAI,CAAC,KAAK,EAAE;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ddItemOptions, 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.trackIndex && options.trackIndex === index) {
|
|
68
67
|
this.playlistItems.splice(index, 1);
|
|
69
68
|
}
|
|
70
|
-
else if (options.
|
|
69
|
+
else if (options.trackId && options.trackId === 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();
|