@capgo/capacitor-media-session 8.0.11 → 8.0.13
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/build.gradle
CHANGED
|
@@ -31,7 +31,7 @@ android {
|
|
|
31
31
|
buildTypes {
|
|
32
32
|
release {
|
|
33
33
|
minifyEnabled false
|
|
34
|
-
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
|
34
|
+
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
lintOptions {
|
|
@@ -30,7 +30,7 @@ import org.json.JSONObject;
|
|
|
30
30
|
@CapacitorPlugin(name = "MediaSession")
|
|
31
31
|
public class MediaSessionPlugin extends Plugin {
|
|
32
32
|
|
|
33
|
-
private final String pluginVersion = "8.0.
|
|
33
|
+
private final String pluginVersion = "8.0.13";
|
|
34
34
|
|
|
35
35
|
private static final String TAG = "CapgoMediaSession";
|
|
36
36
|
|
|
@@ -4,7 +4,7 @@ import MediaPlayer
|
|
|
4
4
|
|
|
5
5
|
@objc(MediaSessionPlugin)
|
|
6
6
|
public class MediaSessionPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
7
|
-
private let pluginVersion: String = "8.0.
|
|
7
|
+
private let pluginVersion: String = "8.0.13"
|
|
8
8
|
public let identifier = "MediaSessionPlugin"
|
|
9
9
|
public let jsName = "MediaSession"
|
|
10
10
|
public let pluginMethods: [CAPPluginMethod] = [
|
|
@@ -72,6 +72,9 @@ public class MediaSessionPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
72
72
|
info[MPNowPlayingInfoPropertyPlaybackRate] = 0.0
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
+
// Keep a default rate so lockscreen scrub remains interactive even while paused.
|
|
76
|
+
info[MPNowPlayingInfoPropertyDefaultPlaybackRate] = 1.0
|
|
77
|
+
|
|
75
78
|
self.updateNowPlayingInfo(info)
|
|
76
79
|
call.resolve()
|
|
77
80
|
}
|
|
@@ -130,6 +133,18 @@ public class MediaSessionPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
130
133
|
self?.notifyListeners("actionHandler", data: ["action": "stop"])
|
|
131
134
|
return .success
|
|
132
135
|
}
|
|
136
|
+
case "seekto":
|
|
137
|
+
commandCenter.changePlaybackPositionCommand.isEnabled = true
|
|
138
|
+
commandCenter.changePlaybackPositionCommand.addTarget { [weak self] event in
|
|
139
|
+
guard let positionEvent = event as? MPChangePlaybackPositionCommandEvent else {
|
|
140
|
+
return .commandFailed
|
|
141
|
+
}
|
|
142
|
+
self?.notifyListeners("actionHandler", data: [
|
|
143
|
+
"action": "seekto",
|
|
144
|
+
"seekTime": positionEvent.positionTime
|
|
145
|
+
])
|
|
146
|
+
return .success
|
|
147
|
+
}
|
|
133
148
|
default:
|
|
134
149
|
call.reject("Unsupported action: \(action)")
|
|
135
150
|
return
|
|
@@ -145,14 +160,17 @@ public class MediaSessionPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
145
160
|
var info = self.nowPlayingInfo
|
|
146
161
|
|
|
147
162
|
if let duration = call.getDouble("duration") {
|
|
148
|
-
info[MPMediaItemPropertyPlaybackDuration] = duration
|
|
163
|
+
info[MPMediaItemPropertyPlaybackDuration] = max(0, duration)
|
|
149
164
|
}
|
|
150
165
|
if let position = call.getDouble("position") {
|
|
151
|
-
info[
|
|
166
|
+
let duration = (info[MPMediaItemPropertyPlaybackDuration] as? Double) ?? call.getDouble("duration") ?? 0
|
|
167
|
+
let clampedPosition = max(0, min(position, max(0, duration)))
|
|
168
|
+
info[MPNowPlayingInfoPropertyElapsedPlaybackTime] = clampedPosition
|
|
152
169
|
}
|
|
153
170
|
if let playbackRate = call.getDouble("playbackRate") {
|
|
154
171
|
info[MPNowPlayingInfoPropertyPlaybackRate] = playbackRate
|
|
155
172
|
}
|
|
173
|
+
info[MPNowPlayingInfoPropertyDefaultPlaybackRate] = 1.0
|
|
156
174
|
|
|
157
175
|
self.updateNowPlayingInfo(info)
|
|
158
176
|
call.resolve()
|
package/package.json
CHANGED