capacitor-plugin-playlist 0.9.1 → 0.9.3

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.
@@ -287,7 +287,13 @@ class PlaylistManager(application: Application) :
287
287
 
288
288
  fun beginPlayback(@IntRange(from = 0) seekPosition: Long, startPaused: Boolean) {
289
289
  currentItem ?: return
290
- super.play(seekPosition, startPaused)
290
+ try {
291
+ super.play(seekPosition, startPaused)
292
+ } catch (e: IllegalStateException) {
293
+ // Android 12+: BackgroundServiceStartNotAllowedException when app is backgrounded
294
+ Log.w(TAG, "beginPlayback: cannot start MediaService while backgrounded: ${e.message}")
295
+ return
296
+ }
291
297
  try {
292
298
  setVolume(volumeLeft, volumeRight)
293
299
  setPlaybackSpeed(playbackSpeed)
@@ -198,11 +198,26 @@ public class PlaylistPlugin: CAPPlugin, StatusUpdater {
198
198
  call.resolve(["position": position])
199
199
  }
200
200
 
201
- public override func handleApplicationWillResignActive(_ notification: Notification) {
201
+ public override func load() {
202
+ NotificationCenter.default.addObserver(
203
+ self,
204
+ selector: #selector(applicationWillResignActive),
205
+ name: UIApplication.willResignActiveNotification,
206
+ object: nil
207
+ )
208
+ NotificationCenter.default.addObserver(
209
+ self,
210
+ selector: #selector(applicationDidBecomeActive),
211
+ name: UIApplication.didBecomeActiveNotification,
212
+ object: nil
213
+ )
214
+ }
215
+
216
+ @objc private func applicationWillResignActive() {
202
217
  audioPlayerImpl.setWebViewActive(false)
203
218
  }
204
219
 
205
- public override func handleApplicationDidBecomeActive(_ notification: Notification) {
220
+ @objc private func applicationDidBecomeActive() {
206
221
  audioPlayerImpl.setWebViewActive(true)
207
222
  audioPlayerImpl.emitPlaybackSnapshot()
208
223
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "capacitor-plugin-playlist",
3
- "version": "0.9.1",
3
+ "version": "0.9.3",
4
4
  "description": "Playlist ",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",