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.
- package/android/.gradle/8.14.3/executionHistory/executionHistory.bin +0 -0
- package/android/.gradle/8.14.3/executionHistory/executionHistory.lock +0 -0
- package/android/.gradle/8.14.3/fileHashes/fileHashes.bin +0 -0
- package/android/.gradle/8.14.3/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/8.14.3/fileHashes/resourceHashesCache.bin +0 -0
- package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/android/src/main/java/org/dwbn/plugins/playlist/playlist/AudioApi.kt +1 -1
- package/android/src/main/java/org/dwbn/plugins/playlist/service/MediaImageProvider.kt +6 -2
- package/android/src/main/java/org/dwbn/plugins/playlist/service/MediaService.kt +33 -5
- package/package.json +1 -1
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -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(
|
|
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.
|
|
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 :
|
|
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
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
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
|
|