@simba-dev/react-native-media-player 3.0.5 → 3.1.0
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/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,51 @@
|
|
|
1
1
|
|
|
2
|
+
## [3.1.0] - 2026-11-03
|
|
3
|
+
|
|
4
|
+
### Fixed
|
|
5
|
+
|
|
6
|
+
- **The Picture-in-Picture action row did nothing.** The three platform buttons — Play/Pause,
|
|
7
|
+
Expand and Close — rendered at the correct size, right beside the platform's own settings /
|
|
8
|
+
expand / close buttons, and pressing ours produced no broadcast at all. The action's
|
|
9
|
+
`PendingIntent` carried an intent that named `PipActionReceiver` explicitly, and an
|
|
10
|
+
explicit broadcast is resolved through the **manifest**; the receiver was a runtime
|
|
11
|
+
registration, so the broadcast resolved to nothing and was dropped before it was ever
|
|
12
|
+
dispatched. Measured on emulator-5554 (API 37) on 2026-11-03: the same action sent
|
|
13
|
+
explicitly was never dispatched (`dispatchTime=--`, in the foreground and in PiP alike),
|
|
14
|
+
while the same action sent implicitly was dispatched in 0 ms. The action intent is now
|
|
15
|
+
implicit, which is what the runtime registration matches on.
|
|
16
|
+
- **A failure to deliver a PiP action was invisible.** `PipActionReceiver` swallowed the
|
|
17
|
+
exception silently — which is how a row of dead buttons could leave not one line in the
|
|
18
|
+
log. The failure is now logged, under the tag `PipActionReceiver`.
|
|
19
|
+
|
|
20
|
+
### Changed
|
|
21
|
+
|
|
22
|
+
- **The library owns the PiP action receiver.** It is registered at runtime, once per
|
|
23
|
+
process, on the application context, at the moment the Picture-in-Picture parameters are
|
|
24
|
+
built — so the platform can never be handed a set of buttons that nothing is listening
|
|
25
|
+
for. Consumers no longer register it, and no longer need to know the class exists.
|
|
26
|
+
|
|
27
|
+
**Action required:** if you registered `PipActionReceiver` yourself, remove that
|
|
28
|
+
registration. Two registrations deliver every action twice, and a play/pause that toggles
|
|
29
|
+
twice leaves playback exactly where it was — the same dead-button symptom with a
|
|
30
|
+
different cause. `PipManager.intentFilter()` is now `internal`, so the compiler points
|
|
31
|
+
at the registration instead of letting it reach a runtime double-delivery bug.
|
|
32
|
+
|
|
33
|
+
### Documentation
|
|
34
|
+
|
|
35
|
+
- The README described the **removed** mechanism: Android's own auto-enter switch, an API 31+
|
|
36
|
+
floor for auto-enter, a PiP action receiver "declared in the manifest", and 26 named
|
|
37
|
+
events where there are 27. It also pointed at a section for "the two lines of Kotlin and
|
|
38
|
+
the JS that goes with them" that did not contain them. All corrected; the auto-enter
|
|
39
|
+
section now carries the Kotlin and the JS a consumer needs, and explains why the consumer
|
|
40
|
+
performs the entry.
|
|
41
|
+
|
|
42
|
+
### Added
|
|
43
|
+
|
|
44
|
+
- `PipActionDeliveryTest` — eight guard tests pinning the contract above: the intent stays
|
|
45
|
+
implicit, the library registers the receiver, the registration cannot happen twice, the
|
|
46
|
+
consumer cannot make it happen twice, a delivery failure is logged, and the manifest
|
|
47
|
+
neither declares the receiver nor duplicates the action strings.
|
|
48
|
+
|
|
2
49
|
## [3.0.5] - 2026-11-03
|
|
3
50
|
|
|
4
51
|
### Changed
|
package/README.md
CHANGED
|
@@ -62,7 +62,8 @@ video, and the two lanes meet in the same bridge:
|
|
|
62
62
|
- **MediaSession and foreground service.** Title, artist and album reach the lock screen and the
|
|
63
63
|
media notification; play, pause, stop, next, previous and seek are advertised to the session, so
|
|
64
64
|
headset buttons and Bluetooth controls work.
|
|
65
|
-
- **Picture-in-Picture.** Manual entry on demand, and
|
|
65
|
+
- **Picture-in-Picture.** Manual entry on demand, and auto-enter on leave on every Android
|
|
66
|
+
version - your app performs the entry itself, after taking its own chrome off screen.
|
|
66
67
|
- **Typed surface.** Config, state, commands and hooks are all typed.
|
|
67
68
|
|
|
68
69
|
## What this is not
|
|
@@ -112,8 +113,13 @@ so re-running `npm install` is safe. Set `SKIP_DOWNLOAD_NATIVE=1` to skip the do
|
|
|
112
113
|
|
|
113
114
|
## Consumer setup
|
|
114
115
|
|
|
115
|
-
The package's own manifest declares a foreground service and
|
|
116
|
-
Activity: playback happens in the Activity your app already has.
|
|
116
|
+
The package's own manifest declares a foreground service and the media button receiver. It
|
|
117
|
+
declares no Activity: playback happens in the Activity your app already has.
|
|
118
|
+
|
|
119
|
+
The Picture-in-Picture action receiver is registered by this package at runtime, once per
|
|
120
|
+
process. You do not register it, and you must not: a second registration would deliver every
|
|
121
|
+
PiP action twice, and a play/pause that toggles twice does nothing at all.
|
|
122
|
+
|
|
117
123
|
|
|
118
124
|
### Picture-in-Picture
|
|
119
125
|
|
|
@@ -330,8 +336,11 @@ import {PlayerProvider} from '@simba-dev/react-native-media-player';
|
|
|
330
336
|
```
|
|
331
337
|
|
|
332
338
|
The resolved config is pushed to the native bridge as JSON. The native side acts on the PiP
|
|
333
|
-
section (it
|
|
334
|
-
with `usePlayerConfig()` and applies itself.
|
|
339
|
+
section (it decides whether your app is told that the user is leaving); the remaining
|
|
340
|
+
sections are values your app reads back with `usePlayerConfig()` and applies itself.
|
|
341
|
+
`DEFAULT_PLAYER_CONFIG` and `DEFAULT_THEME` are exported if you would rather spread and patch.
|
|
342
|
+
|
|
343
|
+
|
|
335
344
|
exported if you would rather spread and patch.
|
|
336
345
|
|
|
337
346
|
## Picture-in-Picture
|
|
@@ -347,15 +356,48 @@ commands.exitPipAndFinish();
|
|
|
347
356
|
`enterPip()` calls `enterPictureInPictureMode()` on the current Activity, so the Activity has to
|
|
348
357
|
declare `android:supportsPictureInPicture="true"` (see [Consumer setup](#consumer-setup)).
|
|
349
358
|
|
|
350
|
-
**Auto-enter on leave** is `config.pip.autoEnterOnLeave` (default `true`)
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
359
|
+
**Auto-enter on leave** is `config.pip.autoEnterOnLeave` (default `true`): it means "enter
|
|
360
|
+
Picture-in-Picture when the user leaves the app".
|
|
361
|
+
|
|
362
|
+
**Your app performs the entry.** The library does not arm Android's own auto-enter switch
|
|
363
|
+
(`PictureInPictureParams.Builder.setAutoEnterEnabled`), because an Activity in
|
|
364
|
+
Picture-in-Picture does not redraw: whatever its window held at the moment of the transition is
|
|
365
|
+
what the PiP window keeps showing. Letting the OS transition the Activity first froze the
|
|
366
|
+
app's own controls into the PiP window, scaled down and dead - measured on device on
|
|
367
|
+
2026-11-03.
|
|
368
|
+
|
|
369
|
+
So the order is yours to keep: take your chrome off screen, let the frame that drew it go by,
|
|
370
|
+
and only then ask for the window. The library tells you WHEN, with two pieces.
|
|
371
|
+
|
|
372
|
+
```kotlin
|
|
373
|
+
// android/app/src/main/java/.../MainActivity.kt
|
|
374
|
+
override fun onUserLeaveHint() {
|
|
375
|
+
super.onUserLeaveHint()
|
|
376
|
+
com.simba.player.mpv.MpvBridgeModule.notifyUserLeaveHint()
|
|
377
|
+
}
|
|
378
|
+
```
|
|
379
|
+
|
|
380
|
+
```ts
|
|
381
|
+
// the consumer's JS - remove your chrome, then ask for the window
|
|
382
|
+
import {subscribePlayerEvent} from '@simba-dev/react-native-media-player';
|
|
383
|
+
|
|
384
|
+
useEffect(() => {
|
|
385
|
+
return subscribePlayerEvent('onUserLeaveHint', () => {
|
|
386
|
+
setChromeVisible(false); // your chrome, your state
|
|
387
|
+
requestAnimationFrame(() => {
|
|
388
|
+
commands.enterPip(); // only now
|
|
389
|
+
});
|
|
390
|
+
});
|
|
391
|
+
}, [commands]);
|
|
392
|
+
```
|
|
393
|
+
|
|
394
|
+
This works on **every** Android version - `onUserLeaveHint()` exists everywhere, and the
|
|
395
|
+
platform's own switch never existed below Android 12.
|
|
355
396
|
|
|
356
397
|
The two PiP flags combine: auto-enter needs `pip.enabled` and `pip.autoEnterOnLeave` to both be
|
|
357
398
|
true.
|
|
358
399
|
|
|
400
|
+
|
|
359
401
|
The Picture-in-Picture action row has three buttons: **Play/Pause**, **Expand** and **Close**.
|
|
360
402
|
They arrive in JS as the `onPipPlayPause`, `onPipExpand` and `onPipClose` events, next to
|
|
361
403
|
`onPipModeChanged`.
|
|
@@ -442,7 +484,7 @@ that position in that file. The defaults are 640×360 at quality 80, exported as
|
|
|
442
484
|
|
|
443
485
|
`getMpvPlayerModule()` returns the native module, or a no-op stand-in when the native side is
|
|
444
486
|
not wired (Jest, web previews) so consumer code stays renderable.
|
|
445
|
-
`subscribePlayerEvent(name, handler)` subscribes to one of the
|
|
487
|
+
`subscribePlayerEvent(name, handler)` subscribes to one of the 27 named events and returns an
|
|
446
488
|
unsubscribe function; `removeAllListeners()`, `setDebugLogging()` and
|
|
447
489
|
`dumpObservedProperties()` are also exported. The event names are typed as `PlayerEventName`.
|
|
448
490
|
|
|
@@ -458,8 +500,16 @@ unsubscribe function; `removeAllListeners()`, `setDebugLogging()` and
|
|
|
458
500
|
before launching, and check `commands.isSurfaceMounted()`.
|
|
459
501
|
|
|
460
502
|
**Picture-in-Picture does not start.** The Activity is missing
|
|
461
|
-
`android:supportsPictureInPicture="true"` or `android:resizeableActivity="true"`.
|
|
462
|
-
leave
|
|
503
|
+
`android:supportsPictureInPicture="true"` or `android:resizeableActivity="true"`. If auto-enter
|
|
504
|
+
on leave does nothing, the Activity is not forwarding `onUserLeaveHint()` - see
|
|
505
|
+
[Picture-in-Picture](#picture-in-picture).
|
|
506
|
+
|
|
507
|
+
**The Picture-in-Picture action row shows three buttons and none of them work.** That was the
|
|
508
|
+
explicit-broadcast bug, fixed in 3.1.0: the action's PendingIntent named the receiver's
|
|
509
|
+
component, and an explicit broadcast is resolved through the manifest, where the receiver was
|
|
510
|
+
never declared. Check that you have not registered a receiver for the PiP actions yourself -
|
|
511
|
+
this package registers one, and a second registration delivers every action twice.
|
|
512
|
+
|
|
463
513
|
|
|
464
514
|
**Gradle fails with `libmpv.so not found at android/src/main/jniLibs/…`.** The postinstall
|
|
465
515
|
download did not run. Re-run `npm install` in the app, or run the script by hand; `SKIP_DOWNLOAD_NATIVE=1`
|
|
@@ -477,11 +527,13 @@ Call `commands.requestNotificationPermission()`.
|
|
|
477
527
|
|
|
478
528
|
- **Android only.** There is no iOS implementation.
|
|
479
529
|
- **No controls.** The library ships none; see [Controls](#controls).
|
|
480
|
-
- **Auto-enter
|
|
481
|
-
|
|
530
|
+
- **Auto-enter on leave is the consumer's to perform.** The library tells your Activity when the
|
|
531
|
+
user is leaving; taking your chrome off screen before asking for the window is your app's
|
|
532
|
+
job, and it has to happen before the Activity is paused.
|
|
482
533
|
- **Most config sections are consumed in JavaScript.** The native side receives the resolved
|
|
483
|
-
config as JSON and acts on the PiP auto-enter
|
|
534
|
+
config as JSON and acts on the PiP auto-enter policy; the rest are values your app reads back
|
|
484
535
|
through `usePlayerConfig()`.
|
|
536
|
+
- **`notifications.channelId` is not read natively.**
|
|
485
537
|
- **`notifications.channelId` is not read natively.** The foreground service creates its own
|
|
486
538
|
notification channel, `simba_player_media_playback`.
|
|
487
539
|
- **The bundled native binaries carry their own licence.** They are built by the mpv-android
|
|
@@ -24,14 +24,25 @@ import com.facebook.react.bridge.ReactContext
|
|
|
24
24
|
* - Notification text with chapter title + progress percentage (Android 12+)
|
|
25
25
|
* - No NEXT/PREV actions (removed for simplicity)
|
|
26
26
|
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
27
|
+
* ## Who owns the action receiver
|
|
28
|
+
*
|
|
29
|
+
* THIS LIBRARY owns it, end to end: [registerActionReceiver] registers
|
|
30
|
+
* [PipActionReceiver] on the application context, once per process. The
|
|
31
|
+
* consumer app does NOT register it and does not need to know the class
|
|
32
|
+
* exists.
|
|
33
|
+
*
|
|
34
|
+
* That ownership is not a preference — it is what makes the buttons
|
|
35
|
+
* work. See [buildRemoteAction] for the measured reason the broadcast
|
|
36
|
+
* has to be IMPLICIT, and [registerActionReceiver] for why there must be
|
|
37
|
+
* exactly ONE registration (two would deliver every action twice, and a
|
|
38
|
+
* play/pause that toggles twice leaves playback exactly where it was —
|
|
39
|
+
* buttons that look alive and do nothing).
|
|
40
|
+
*
|
|
41
|
+
* V12 Phase 9 relocated this object from the consumer app to the module
|
|
42
|
+
* so the consumer's Activity can call `buildPipParams(...)` without
|
|
43
|
+
* crossing the Gradle module boundary. Both sides share the same
|
|
44
|
+
* `com.simba.player.PipManager` FQN, which Gradle resolves to the
|
|
45
|
+
* module's copy at app build time.
|
|
35
46
|
*/
|
|
36
47
|
@RequiresApi(Build.VERSION_CODES.N)
|
|
37
48
|
object PipManager {
|
|
@@ -69,6 +80,17 @@ object PipManager {
|
|
|
69
80
|
chapterTitle: String? = null,
|
|
70
81
|
progressPercentage: String? = null,
|
|
71
82
|
): PictureInPictureParams {
|
|
83
|
+
// The params carry the three RemoteActions, and the platform's PiP
|
|
84
|
+
// action row is the ONLY way they can ever be fired. So the
|
|
85
|
+
// receiver that serves them has to exist before these params do.
|
|
86
|
+
//
|
|
87
|
+
// Registering here — at the single place the params are built —
|
|
88
|
+
// makes it impossible to hand the platform a set of buttons that
|
|
89
|
+
// nothing is listening for. That was the measured defect on
|
|
90
|
+
// 2026-11-03: the row rendered three buttons at the right size
|
|
91
|
+
// and none of them did anything.
|
|
92
|
+
registerActionReceiver(context)
|
|
93
|
+
|
|
72
94
|
val actions = mutableListOf<RemoteAction>()
|
|
73
95
|
|
|
74
96
|
// Play/Pause
|
|
@@ -137,10 +159,16 @@ object PipManager {
|
|
|
137
159
|
// The platform's auto-enter switch makes the SYSTEM transition the
|
|
138
160
|
// activity into PiP when the user leaves the app, without the app
|
|
139
161
|
// being able to do anything first. That is the wrong order for a
|
|
140
|
-
// consumer that draws its own chrome over the picture
|
|
141
|
-
//
|
|
142
|
-
//
|
|
143
|
-
//
|
|
162
|
+
// consumer that draws its own chrome over the picture.
|
|
163
|
+
//
|
|
164
|
+
// The reason is NOT that the window freezes - an Activity in PiP is
|
|
165
|
+
// "paused, but rendering" (source.android.com/docs/core/display/
|
|
166
|
+
// pip). What stops is REACT: RN pauses the React scheduler when
|
|
167
|
+
// the Activity is paused, so a React commit cannot land and no
|
|
168
|
+
// frame is produced. The switch transitions the Activity before
|
|
169
|
+
// the consumer can unmount its chrome, so the chrome is still
|
|
170
|
+
// mounted when the PiP window is created - and with no frame
|
|
171
|
+
// coming, it stays there: dead and scaled down.
|
|
144
172
|
//
|
|
145
173
|
// Measured on device on 2026-11-03: the consumer's full expanded
|
|
146
174
|
// chrome (header band, scrub row, +-10 buttons, the big pause
|
|
@@ -184,9 +212,36 @@ object PipManager {
|
|
|
184
212
|
action: String,
|
|
185
213
|
requestCode: Int,
|
|
186
214
|
): RemoteAction {
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
215
|
+
// The intent is IMPLICIT — it carries the action and NOTHING else.
|
|
216
|
+
//
|
|
217
|
+
// It used to name the component explicitly
|
|
218
|
+
// (`setClass(context, PipActionReceiver::class.java)`). THAT was
|
|
219
|
+
// the reason the PiP buttons did NOTHING, measured on
|
|
220
|
+
// emulator-5554 (API 37) on 2026-11-03:
|
|
221
|
+
//
|
|
222
|
+
// * The platform's PiP action row rendered at the correct size,
|
|
223
|
+
// right beside the platform's own settings / expand / close
|
|
224
|
+
// buttons — and all three of THOSE worked.
|
|
225
|
+
// * Tapping ours produced NO broadcast at all:
|
|
226
|
+
// `dumpsys activity broadcasts` held no record of the action,
|
|
227
|
+
// and the platform's own gear button opened the PiP settings
|
|
228
|
+
// screen in the very same gesture.
|
|
229
|
+
//
|
|
230
|
+
// The cause is how the framework resolves an EXPLICIT broadcast:
|
|
231
|
+
// it looks the component up through the MANIFEST.
|
|
232
|
+
// `PipActionReceiver` is not declared there — it is a runtime
|
|
233
|
+
// registration — so the explicit broadcast resolved to no
|
|
234
|
+
// receiver and was dropped before it was ever dispatched
|
|
235
|
+
// (`dumpsys` showed `dispatchTime=--`, foreground and background
|
|
236
|
+
// alike).
|
|
237
|
+
//
|
|
238
|
+
// The same action sent IMPLICITLY was dispatched in 0 ms, and
|
|
239
|
+
// that is the proof: the receiver was registered and matching the
|
|
240
|
+
// whole time. Only the component was the problem.
|
|
241
|
+
//
|
|
242
|
+
// An implicit intent is matched by ACTION, which is exactly what
|
|
243
|
+
// the runtime registration filters on.
|
|
244
|
+
val intent = Intent(action)
|
|
190
245
|
val pendingIntent = PendingIntent.getBroadcast(
|
|
191
246
|
context,
|
|
192
247
|
requestCode,
|
|
@@ -203,13 +258,57 @@ object PipManager {
|
|
|
203
258
|
|
|
204
259
|
// ── Intent Filter ──────────────────────────────────────────────────────
|
|
205
260
|
|
|
206
|
-
|
|
261
|
+
/**
|
|
262
|
+
* The filter the runtime registration matches on.
|
|
263
|
+
*
|
|
264
|
+
* `internal` on purpose: registering the receiver is THIS library's
|
|
265
|
+
* job (see [registerActionReceiver]), and a public helper would
|
|
266
|
+
* only invite a consumer to register a second receiver for the same
|
|
267
|
+
* three actions. Two receivers means every action is delivered
|
|
268
|
+
* twice, and a play/pause that toggles twice leaves playback exactly
|
|
269
|
+
* where it was — a row of buttons that look alive and do nothing.
|
|
270
|
+
*/
|
|
271
|
+
internal fun intentFilter(): IntentFilter {
|
|
207
272
|
return IntentFilter().apply {
|
|
208
273
|
addAction(ACTION_PLAY_PAUSE)
|
|
209
274
|
addAction(ACTION_EXPAND)
|
|
210
275
|
addAction(ACTION_CLOSE)
|
|
211
276
|
}
|
|
212
277
|
}
|
|
278
|
+
|
|
279
|
+
// ── Receiver registration ─────────────────────────────────────────────
|
|
280
|
+
|
|
281
|
+
/**
|
|
282
|
+
* Registers [PipActionReceiver] for the three PiP actions — ONCE per
|
|
283
|
+
* process.
|
|
284
|
+
*
|
|
285
|
+
* The application context is used on purpose: the receiver has to
|
|
286
|
+
* outlive any Activity, because the platform's PiP action row can
|
|
287
|
+
* fire while the consumer's Activity is paused inside PiP, and long
|
|
288
|
+
* after a configuration change has replaced it.
|
|
289
|
+
*
|
|
290
|
+
* The once-per-process guard matters because the React context — and
|
|
291
|
+
* with it this module — can be recreated (a debug reload, a process
|
|
292
|
+
* restart), and registering again would deliver every action twice.
|
|
293
|
+
*/
|
|
294
|
+
internal fun registerActionReceiver(context: Context) {
|
|
295
|
+
val appContext = context.applicationContext
|
|
296
|
+
synchronized(registrationLock) {
|
|
297
|
+
if (registered) return
|
|
298
|
+
val receiver = PipActionReceiver()
|
|
299
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
|
300
|
+
appContext.registerReceiver(receiver, intentFilter(), Context.RECEIVER_EXPORTED)
|
|
301
|
+
} else {
|
|
302
|
+
appContext.registerReceiver(receiver, intentFilter())
|
|
303
|
+
}
|
|
304
|
+
registered = true
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
private val registrationLock = Any()
|
|
309
|
+
|
|
310
|
+
@Volatile
|
|
311
|
+
private var registered = false
|
|
213
312
|
}
|
|
214
313
|
|
|
215
314
|
// ── BroadcastReceiver for PiP Actions ──────────────────────────────────────
|
|
@@ -218,18 +317,26 @@ object PipManager {
|
|
|
218
317
|
* Receives PiP RemoteAction broadcasts and forwards them to the React Native
|
|
219
318
|
* event layer via [com.facebook.react.modules.core.DeviceEventManagerModule.RCTDeviceEventEmitter].
|
|
220
319
|
*
|
|
221
|
-
* Registered
|
|
222
|
-
*
|
|
223
|
-
*
|
|
320
|
+
* Registered by THIS library, once per process, on the application context
|
|
321
|
+
* — see [PipManager.registerActionReceiver]. The consumer app does not
|
|
322
|
+
* register it and does not need to know the class exists.
|
|
224
323
|
*
|
|
225
|
-
*
|
|
226
|
-
*
|
|
227
|
-
*
|
|
324
|
+
* It is a RUNTIME registration on purpose: the three action strings are
|
|
325
|
+
* owned by [PipManager] as Kotlin constants, and a manifest declaration
|
|
326
|
+
* would have to repeat them as literals — two owners for one fact. The
|
|
327
|
+
* broadcast those constants feed is implicit, so it matches a runtime
|
|
328
|
+
* registration by action. (An EXPLICIT broadcast would need a manifest
|
|
329
|
+
* declaration instead; see [PipManager.buildRemoteAction] for the
|
|
330
|
+
* measured reason that shape never worked.)
|
|
228
331
|
*
|
|
229
332
|
* v3: Handles 3 actions — play/pause, expand (restore fullscreen), close (end session).
|
|
230
333
|
*/
|
|
231
334
|
class PipActionReceiver : BroadcastReceiver() {
|
|
232
335
|
|
|
336
|
+
private companion object {
|
|
337
|
+
const val TAG = "PipActionReceiver"
|
|
338
|
+
}
|
|
339
|
+
|
|
233
340
|
override fun onReceive(context: Context, intent: Intent) {
|
|
234
341
|
when (intent.action) {
|
|
235
342
|
PipManager.ACTION_PLAY_PAUSE -> {
|
|
@@ -250,9 +357,15 @@ class PipActionReceiver : BroadcastReceiver() {
|
|
|
250
357
|
reactContext
|
|
251
358
|
.getJSModule(com.facebook.react.modules.core.DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
|
|
252
359
|
?.emit(eventName, params)
|
|
253
|
-
} catch (
|
|
254
|
-
// React context not available —
|
|
255
|
-
// the JS bundle has unloaded
|
|
360
|
+
} catch (e: Exception) {
|
|
361
|
+
// The React context is not available — the broadcast can arrive
|
|
362
|
+
// after the JS bundle has unloaded, and there is no UI to update
|
|
363
|
+
// in that case.
|
|
364
|
+
//
|
|
365
|
+
// It is still LOGGED, and that is the point. A silent catch
|
|
366
|
+
// here is how the PiP action row could render three buttons
|
|
367
|
+
// that did nothing, with not one line in the log to say so.
|
|
368
|
+
android.util.Log.w(TAG, "cannot emit $eventName: no React context", e)
|
|
256
369
|
}
|
|
257
370
|
}
|
|
258
371
|
|
|
@@ -2359,10 +2359,13 @@ class MpvBridgeModule(reactContext: ReactApplicationContext) :
|
|
|
2359
2359
|
* What this does NOT do any more: arm the platform's own switch
|
|
2360
2360
|
* (`PictureInPictureParams.Builder.setAutoEnterEnabled`, API 31+).
|
|
2361
2361
|
* The platform's switch makes the SYSTEM transition the activity into
|
|
2362
|
-
* PiP without the consumer being able to do anything first
|
|
2363
|
-
* Activity in PiP
|
|
2364
|
-
*
|
|
2365
|
-
*
|
|
2362
|
+
* PiP without the consumer being able to do anything first. The
|
|
2363
|
+
* Activity in PiP is "paused, but rendering" - what stops is REACT:
|
|
2364
|
+
* its scheduler is paused with the Activity, so no commit lands and
|
|
2365
|
+
* no frame is produced. So a consumer that draws its own chrome over
|
|
2366
|
+
* the picture still had that chrome mounted when the PiP window was
|
|
2367
|
+
* created, and with no frame coming it stayed there: dead and scaled
|
|
2368
|
+
* down. Measured on device on 2026-11-03.
|
|
2366
2369
|
* See `PipManager.buildPipParams` for the full account.
|
|
2367
2370
|
*
|
|
2368
2371
|
* What it does now: the policy is remembered (so
|
|
@@ -2387,10 +2390,10 @@ class MpvBridgeModule(reactContext: ReactApplicationContext) :
|
|
|
2387
2390
|
// The policy is remembered so `notifyUserLeaveHint()` knows
|
|
2388
2391
|
// whether to tell the consumer that it should enter PiP. The
|
|
2389
2392
|
// platform's OWN auto-enter switch is NOT armed: the system
|
|
2390
|
-
// would transition the activity
|
|
2391
|
-
//
|
|
2392
|
-
//
|
|
2393
|
-
//
|
|
2393
|
+
// would transition the activity before the consumer could
|
|
2394
|
+
// remove its chrome, and React cannot commit a frame while
|
|
2395
|
+
// the Activity is paused - so the consumer's chrome would be
|
|
2396
|
+
// still mounted in the PiP window, dead and scaled down. See
|
|
2394
2397
|
// `PipManager.buildPipParams` for the measurement.
|
|
2395
2398
|
pipAutoEnterForCompanion = desired
|
|
2396
2399
|
} catch (t: Throwable) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@simba-dev/react-native-media-player",
|
|
3
|
-
"version": "3.0
|
|
3
|
+
"version": "3.1.0",
|
|
4
4
|
"description": "React Native video & audio player powered by libmpv — Picture-in-Picture, MediaSession, foreground service, and a customizable TypeScript UI. Built for Android. Designed as a drop-in replacement for react-native-video / react-native-track-player / expo-av. See CHANGELOG.md for per-version notes.",
|
|
5
5
|
"main": "src/index.ts",
|
|
6
6
|
"types": "src/index.ts",
|