capacitor-plugin-playlist 0.8.3 → 0.8.5

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.
@@ -50,7 +50,7 @@ class AudioApi(context: Context) : BaseMediaApi() {
50
50
 
51
51
  audioPlayer.setWakeLevel(PowerManager.PARTIAL_WAKE_LOCK)
52
52
  audioPlayer.setAudioAttributes(getAudioAttributes(C.USAGE_MEDIA, C.AUDIO_CONTENT_TYPE_MUSIC))
53
- audioPlayer.setAnalyticsListener(EventLogger(null))
53
+ audioPlayer.setAnalyticsListener(EventLogger())
54
54
  }
55
55
 
56
56
  override fun play() {
@@ -5,7 +5,7 @@ import android.graphics.Bitmap
5
5
  import android.graphics.BitmapFactory
6
6
  import com.bumptech.glide.Glide
7
7
  import com.bumptech.glide.RequestManager
8
- import com.bumptech.glide.request.target.SimpleTarget
8
+ import com.bumptech.glide.request.target.CustomTarget
9
9
  import com.bumptech.glide.request.transition.Transition
10
10
  import com.devbrackets.android.playlistcore.components.image.ImageProvider
11
11
  import org.dwbn.plugins.playlist.FakeR
@@ -63,10 +63,14 @@ class MediaImageProvider(
63
63
  *
64
64
  * **NOTE:** This is a Glide Image loader class
65
65
  */
66
- private inner class RemoteViewImageTarget : SimpleTarget<Bitmap>() {
66
+ private inner class RemoteViewImageTarget : CustomTarget<Bitmap>() {
67
67
  override fun onResourceReady(resource: Bitmap, transition: Transition<in Bitmap>?) {
68
68
  artworkImage = resource
69
69
  }
70
+
71
+ override fun onLoadCleared(placeholder: android.graphics.drawable.Drawable?) {
72
+ // No cleanup needed
73
+ }
70
74
  }
71
75
 
72
76
  init {
@@ -1,8 +1,11 @@
1
1
  package org.dwbn.plugins.playlist.service
2
2
 
3
3
  import android.app.Notification
4
+ import android.app.Service
5
+ import android.content.Intent
4
6
  import android.content.pm.ServiceInfo
5
7
  import android.os.Build
8
+ import android.util.Log
6
9
  import com.devbrackets.android.playlistcore.components.playlisthandler.PlaylistHandler
7
10
  import com.devbrackets.android.playlistcore.service.BasePlaylistService
8
11
  import org.dwbn.plugins.playlist.App
@@ -17,6 +20,10 @@ import org.dwbn.plugins.playlist.service.MediaImageProvider.OnImageUpdatedListen
17
20
  * the application specific information required.
18
21
  */
19
22
  class MediaService : BasePlaylistService<AudioTrack, PlaylistManager>() {
23
+ companion object {
24
+ private const val TAG = "MediaService"
25
+ }
26
+
20
27
  override fun onCreate() {
21
28
  super.onCreate()
22
29
  // Adds the audio player implementation, otherwise there's nothing to play media with
@@ -35,17 +42,38 @@ class MediaService : BasePlaylistService<AudioTrack, PlaylistManager>() {
35
42
  playlistManager.mediaPlayers.clear()
36
43
  }
37
44
 
45
+ override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
46
+ return try {
47
+ super.onStartCommand(intent, flags, startId)
48
+ } catch (e: android.app.ForegroundServiceStartNotAllowedException) {
49
+ // Android 12+ blocks foreground service start from background
50
+ // Log the error but don't crash - service can still function without foreground status
51
+ Log.w(TAG, "Cannot start foreground service: app is in background", e)
52
+ // Return START_NOT_STICKY so service won't be restarted if killed
53
+ // The service will continue as a regular service (may be killed by system)
54
+ Service.START_NOT_STICKY
55
+ }
56
+ }
57
+
38
58
  override fun runAsForeground(notificationId: Int, notification: Notification) {
39
59
  if (inForeground) {
40
60
  return
41
61
  }
42
62
 
43
63
  inForeground = true
44
- if (Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU) {
45
- startForeground(notificationId, notification)
46
- } else {
47
- startForeground(notificationId, notification,
48
- ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PLAYBACK)
64
+ try {
65
+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU) {
66
+ startForeground(notificationId, notification)
67
+ } else {
68
+ startForeground(notificationId, notification,
69
+ ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PLAYBACK)
70
+ }
71
+ } catch (e: android.app.ForegroundServiceStartNotAllowedException) {
72
+ // Android 12+ blocks foreground service start from background
73
+ // Log the error but don't crash - service can still function without foreground status
74
+ Log.w(TAG, "Cannot start foreground service: app is in background", e)
75
+ inForeground = false
76
+ // Service will continue as a regular service (may be killed by system)
49
77
  }
50
78
  }
51
79
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "capacitor-plugin-playlist",
3
- "version": "0.8.3",
3
+ "version": "0.8.5",
4
4
  "description": "Playlist ",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",