@simba-dev/react-native-media-player 3.2.0 → 3.3.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,88 @@
1
1
 
2
+ ## [3.3.0] - 2026-11-04
3
+
4
+ ### Fixed
5
+
6
+ - **The Picture-in-Picture window showed the app's full expanded chrome, scaled down.** The PiP
7
+ window opened, and the video played under it — but the header band, the scrub row with its frozen
8
+ clock, the ±10 buttons, the big pause button and the volume row were painted into the window
9
+ too, at a fraction of their size, and their buttons were dead. Measured on emulator-5554 (API
10
+ 37) on 2026-11-03.
11
+
12
+ **3.2.0's claim is retracted.** 3.2.0 said the library hides the consumer's chrome on the HOME
13
+ path. It did hide it — natively, with `visibility = View.GONE` — but the hide **could not reach
14
+ the pixels**: `Activity.onUserLeaveHint()` is called as part of the Activity's PAUSE
15
+ transaction, and there is **no frame between the hide and the pause**. The PiP window is built
16
+ from the window's last rendered buffer, and that buffer still held the chrome. The chrome was
17
+ hidden and stayed visible.
18
+
19
+ Two mechanisms keep the app's chrome out of the PiP window now, and they are layered:
20
+
21
+ 1. **The crop (primary).** The platform crops the app's window to the rect in
22
+ `PictureInPictureParams.setSourceRectHint(...)` and scales that crop into the PiP window. The
23
+ library now **commits** the params to the Activity with
24
+ `Activity.setPictureInPictureParams(...)` — early, and every time the picture's geometry,
25
+ the video's shape or the playback state changes — instead of handing them over only at the
26
+ entry moment. A source rect hint that is only handed over at the entry moment never crops
27
+ anything: the PiP window then shows the whole window, scaled down. Google's own
28
+ `androidx.core-pip` does exactly this — it tracks the player view's bounds and commits the
29
+ params as they change.
30
+
31
+ The hint is the region of the window the **video** occupies (the video's own frame inside
32
+ the picture box, letterboxed), not the picture box's rect — the box fills the screen, so
33
+ hinting the box crops the whole screen into the PiP window, chrome included.
34
+
35
+ 2. **The hide (second line of defence).** The chrome the app draws *over* the video — the big
36
+ pause button, the scrub row — is inside the crop, so the crop cannot remove it. It is now
37
+ hidden from `onPictureInPictureModeChanged(true)`: after the platform has entered PiP, and
38
+ while the activity is "paused, but rendering", so the invalidation is drawn. A `nativeID`
39
+ that no view carries is no longer a refusal — it means the chrome is **already hidden**, and
40
+ the entry goes on.
41
+
42
+ - **The PiP action row was a second copy of the platform's own buttons.** The library's Expand
43
+ and Close actions are gone: the platform renders its own expand / close / settings affordances
44
+ in the PiP window, and the library's row duplicated them. The row now carries **exactly one**
45
+ action, play/pause, with a **state-driven icon** — the pause icon while the video is playing,
46
+ the play icon while it is paused — and the params are re-committed when the playback state
47
+ changes so the platform picks the new icon up.
48
+
49
+ - **The play/pause button went through JavaScript to pause the video.** The broadcast now
50
+ reaches the engine directly (`PlaybackHost` + `MPVLib`), the same way
51
+ `MediaPlaybackService`'s session callbacks drive playback. The old path was
52
+ broadcast → JS event → bridge → mpv, and this library's own code recorded why that shape is
53
+ fragile: "the broadcast can arrive after the JS bundle has unloaded". The `onPipPlayPause`
54
+ event still exists in the JS API for compatibility, but it is not the mechanism that pauses
55
+ playback.
56
+
57
+ - **The source rect hint was applied from Android 12 only.** `setSourceRectHint(Rect)` has been
58
+ available since API 26; react-native-video and expo-video both hand it over from API 26.
59
+
60
+ ### Changed
61
+
62
+ - **Android 12+ uses the platform's own auto-enter switch.** The library arms
63
+ `setAutoEnterEnabled(true)` — but **only while media is loaded**, and disarms it when playback
64
+ stops, so browsing the Home screen with nothing playing cannot throw the user into a PiP
65
+ window. While auto-enter is armed, `notifyUserLeaveHint(activity)` is a logged no-op: ATMS
66
+ refuses an explicit `enterPictureInPictureMode()` while auto-enter is enabled ("auto-enter
67
+ should take in place instead"). The explicit entry is kept for API 24–30. The consumer's
68
+ Activity keeps calling `MpvBridgeModule.notifyUserLeaveHint(this)` from `onUserLeaveHint()` —
69
+ unchanged, and correct on every API level.
70
+
71
+ ### Documentation
72
+
73
+ - Every sentence in this library that said React Native pauses its own scheduler together with the
74
+ Activity was **mechanically wrong**, and a wrong reason sends the next reader looking for the
75
+ fix in the wrong place. React Native freezes in **two** ways while the Activity is paused:
76
+ `FabricUIManager.onHostPause()` removes the DISPATCH_UI frame callback, so mount items are
77
+ never applied to native views, and `JavaTimerManager.onHostPause()` freezes the timer registry,
78
+ so `requestAnimationFrame` never fires. The JS runtime itself keeps running. Corrected in
79
+ `MpvBridgeModule.kt`, `PipManager.kt`, `PipNativeEntry.kt`, `MpvPlayerModule.ts` and
80
+ `config.ts`.
81
+
82
+ - The claim that an Activity in Picture-in-Picture never repaints its window was corrected too:
83
+ the app window's **UI layer** stops producing frames while it is paused, while a `SurfaceView`
84
+ keeps compositing.
85
+
2
86
  ## [3.2.0] - 2026-11-03
3
87
 
4
88
  ### Fixed
@@ -11,18 +95,21 @@
11
95
 
12
96
  The cause was measured, not guessed. `Activity.onUserLeaveHint()` fired and the JS handler ran
13
97
  immediately, but the effect that would have driven the entry ran **5.7 s late** and the
14
- `requestAnimationFrame` **never fired**. React Native pauses the React scheduler with the
15
- Activity, so a React commit cannot land and there is no frame clock once the Activity is
16
- backgrounded. The entry therefore has to be **native**, inside `onUserLeaveHint()`, before
17
- `onPause`.
98
+ `requestAnimationFrame` **never fired**. React Native freezes in TWO ways while the Activity is
99
+ paused — `FabricUIManager.onHostPause()` removes the DISPATCH_UI frame callback, so mount items
100
+ are never applied to native views, and `JavaTimerManager.onHostPause()` freezes the timer
101
+ registry, so `requestAnimationFrame` never fires. The entry therefore has to be **native**,
102
+ inside `onUserLeaveHint()`, before `onPause`.
18
103
 
19
104
  The library now performs the HOME-path entry itself:
20
105
 
21
- - the consumer's chrome is hidden with a **native View-system mutation**
22
- (`visibility = View.GONE`), which lands without a React commit and without a frame clock;
23
- - the PiP parameters are built **after** the hide, by the same builder the JS path uses;
24
- - the chrome is restored when Picture-in-Picture ends, and immediately if the OS refuses the
25
- entry.
106
+ - the PiP parameters are built by the same builder the JS path uses, and handed to the platform;
107
+ - the chrome is restored when Picture-in-Picture ends.
108
+
109
+ > **Superseded by 3.3.0.** This release made the PiP window **open** — it did not make the
110
+ > chrome go away. The chrome hide it added could not reach the pixels (there is no frame
111
+ > between the hide and the pause), and the source rect hint it passed at the entry moment never
112
+ > cropped the window. See the 3.3.0 entry above for what actually fixed it.
26
113
 
27
114
  **Action required:** your Activity has to hand over the Activity.
28
115
 
@@ -49,10 +136,7 @@
49
136
 
50
137
  The `nativeID` literal belongs to the consumer; the library never hardcodes one of its own.
51
138
  Omit `chromeNativeId` if your app draws no chrome of its own — the library then enters
52
- Picture-in-Picture without hiding anything. If the id is set and **no view carries it**, the
53
- library **refuses** the entry and logs a warning naming the id: entering PiP with the chrome
54
- still mounted paints the app's dead chrome into the PiP window, which is the defect this
55
- release exists to fix.
139
+ Picture-in-Picture without hiding anything.
56
140
 
57
141
  ### Removed
58
142
 
@@ -70,8 +154,7 @@
70
154
 
71
155
  - `MpvBridgeModule.notifyUserLeaveHint()` is now
72
156
  `notifyUserLeaveHint(activity: Activity): Boolean`. It takes the Activity — the entry happens
73
- on it, and the chrome is searched under its window — and returns the OS's own answer:
74
- `true` when the Activity entered Picture-in-Picture.
157
+ on it — and returns the OS's own answer: `true` when the Activity entered Picture-in-Picture.
75
158
  - **The PiP parameters have ONE owner.** The JS path (`enterPip`) and the native path
76
159
  (`notifyUserLeaveHint`) build them through the same function, so the two cannot drift apart.
77
160
  - The native path reports the title from mpv's `media-title` — which IS the title the consumer
@@ -80,14 +163,13 @@
80
163
 
81
164
  ### Documentation
82
165
 
83
- - Five places in this library still carried the false claim that "an Activity in
84
- Picture-in-Picture does not redraw". The accurate statement is that an Activity in PiP is
85
- **"paused, but rendering"** (AOSP) — the window keeps rendering; what stops is **REACT**,
86
- because React Native pauses the React scheduler with the Activity. The ORDER still matters — the
87
- PiP window keeps whatever the Activity's window held at the transition — but the REASON was
88
- wrong, and a wrong reason sends the next reader looking for the fix in the wrong place.
89
- Corrected in `MpvBridgeModule.kt`, `CHANGELOG.md`, `README.md`, `MpvPlayerModule.ts` and
90
- `config.ts`.
166
+ - Five places in this library still carried the false claim that an Activity in Picture-in-
167
+ Picture never repaints its window. The accurate statement is that the app window's **UI
168
+ layer** stops producing frames while the Activity is paused, while a `SurfaceView` keeps
169
+ compositing; and what stops is **REACT**, in two ways —
170
+ `FabricUIManager.onHostPause()` removes the DISPATCH_UI frame callback, and
171
+ `JavaTimerManager.onHostPause()` freezes the timer registry. Corrected in
172
+ `MpvBridgeModule.kt`, `CHANGELOG.md`, `README.md`, `MpvPlayerModule.ts` and `config.ts`.
91
173
 
92
174
  ### Added
93
175
 
@@ -157,10 +239,10 @@
157
239
  the SYSTEM transition the activity into PiP when the user leaves the app,
158
240
  with the consumer unable to do anything first. That is the wrong order for a
159
241
  consumer that draws its own chrome over the picture, because an Activity in
160
- PiP is "paused, but rendering" (AOSP) - what stops is REACT: RN pauses the
161
- React scheduler with the Activity, so a React commit cannot land and no frame
162
- is produced. So whatever its window held at the transition is what the PiP
163
- window keeps showing. Measured on device on 2026-11-03, the
242
+ PiP is "paused, but rendering" (AOSP) - what stops is REACT: React Native
243
+ freezes in two ways while the Activity is paused, so a React commit cannot
244
+ land and no frame is produced. So whatever its window held at the transition
245
+ is what the PiP window keeps showing. Measured on device on 2026-11-03, the
164
246
  consumer's full expanded chrome was painted into the PiP window, its
165
247
  buttons were dead, and its clock was frozen three minutes behind the real
166
248
  position.
package/README.md CHANGED
@@ -369,7 +369,7 @@ override fun onUserLeaveHint() {
369
369
  }
370
370
  ```
371
371
 
372
- The library then hides your chrome, asks the OS for the window, and brings your chrome back when
372
+ The library then asks the OS for the window, hides your chrome, and brings your chrome back when
373
373
  Picture-in-Picture ends. It returns whether the OS accepted the entry, so you can log it:
374
374
 
375
375
  ```kotlin
@@ -379,19 +379,35 @@ val entered = com.simba.player.mpv.MpvBridgeModule.notifyUserLeaveHint(this)
379
379
  ### Why it is native, and why your Activity hands over the Activity
380
380
 
381
381
  `Activity.onUserLeaveHint()` is the only hook Android gives you BEFORE the Activity is paused.
382
- `onPictureInPictureModeChanged(true)` arrives after `onPause`, which is too late to change what
383
- the window holds.
384
382
 
385
- And by then, React Native has already paused the React scheduler with the Activity, so a React
386
- commit cannot land and there is no frame clock. Measured on emulator-5554 (API 37) on 2026-11-03:
387
- the JS handler ran immediately, the effect that would have driven the entry ran **5.7 s late**, and
388
- the `requestAnimationFrame` **never fired**. So the entry has to happen in native code, and the
389
- chrome has to be hidden with a native View-system mutation (`visibility = View.GONE`), which lands
390
- without a React commit and without a frame clock.
391
-
392
- An Activity in Picture-in-Picture is "paused, but rendering" (AOSP) - the window keeps rendering;
393
- what stops is REACT. So the PiP window keeps whatever your window held at the moment of the
394
- transition: the chrome has to be GONE before the entry.
383
+ And by then, React Native has ALREADY frozen, in two ways: `FabricUIManager.onHostPause()`
384
+ removes the DISPATCH_UI frame callback, so mount items are never applied to native views, and
385
+ `JavaTimerManager.onHostPause()` freezes the timer registry, so `requestAnimationFrame` never
386
+ fires. The JS runtime itself keeps running. Measured on emulator-5554 (API 37) on 2026-11-03: the
387
+ JS handler ran immediately, the effect that would have driven the entry ran **5.7 s late**, and
388
+ the `requestAnimationFrame` **never fired**. So the entry has to happen in native code.
389
+
390
+ While the Activity is paused, the app window's **UI layer** stops producing frames, while a
391
+ `SurfaceView` keeps compositing. That is why the chrome is hidden from
392
+ `onPictureInPictureModeChanged(true)` and not from `onUserLeaveHint()`: `onUserLeaveHint()` is
393
+ called as part of the Activity's PAUSE transaction, and there is **no frame between the hide and
394
+ the pause** — a hide applied there never reaches the pixels. (The 3.2.0 release claimed otherwise;
395
+ the 3.3.0 release retracted it.)
396
+
397
+ ### How your chrome is kept out of the PiP window
398
+
399
+ Two mechanisms, layered:
400
+
401
+ 1. **The crop (primary).** The platform crops your window to the rect in
402
+ `PictureInPictureParams.setSourceRectHint(...)` and scales that crop into the PiP window. The
403
+ library **commits** the params to your Activity with
404
+ `Activity.setPictureInPictureParams(...)` — early, and again whenever the picture's geometry,
405
+ the video's shape or the playback state changes — because the platform builds the PiP window
406
+ from the LAST COMMITTED params. A hint handed over only at the entry moment never crops
407
+ anything, and the PiP window then shows your whole window, scaled down.
408
+ 2. **The hide (second line of defence).** The chrome you draw *over* the video is inside the
409
+ crop, so the crop cannot remove it. The library hides your chrome root when Picture-in-
410
+ Picture starts.
395
411
 
396
412
  ### Telling the library which view is your chrome
397
413
 
@@ -416,21 +432,22 @@ about it:
416
432
  ```
417
433
 
418
434
  The library finds that view with React Native's own lookup (`ReactFindViewUtil.findView`), under
419
- your Activity's window decor view, and hides it natively before it asks for the window. The
435
+ your Activity's window decor view, and hides it natively when Picture-in-Picture starts. The
420
436
  `nativeID` literal is yours - the library never hardcodes one of its own.
421
437
 
422
438
  Omit `chromeNativeId` if your app draws no chrome of its own: the library then enters
423
439
  Picture-in-Picture without hiding anything.
424
440
 
425
- **If the `nativeID` is set and no view carries it, the library REFUSES the entry** and logs a
426
- warning naming the id. Entering Picture-in-Picture with the chrome still mounted paints your dead
427
- controls into the PiP window, scaled down and dead - that is the defect this path exists to fix, so
428
- the library declines rather than reproduce it.
441
+ **If the `nativeID` is set and no view carries it, the chrome is already hidden** - your own
442
+ button path unmounts it in React before it asks for the window - so the library logs that and
443
+ carries on. It never refuses the entry over a missing view.
429
444
 
430
- The library deliberately does NOT arm Android's own auto-enter switch
431
- (`PictureInPictureParams.Builder.setAutoEnterEnabled`): that makes the OS transition the Activity
432
- with no chance to remove your chrome, and the chrome it froze into the PiP window on 2026-11-03 was
433
- scaled down and dead.
445
+ On **Android 12+** the library also arms Android's own auto-enter switch
446
+ (`PictureInPictureParams.Builder.setAutoEnterEnabled`), but **only while media is loaded**, and it
447
+ disarms it when playback stops: browsing the Home screen with nothing playing must not throw you
448
+ into a PiP window of a stopped session. While the switch is armed, the OS performs the entry
449
+ itself, and the library's explicit `enterPictureInPictureMode()` call is skipped (the platform
450
+ refuses it while auto-enter is enabled).
434
451
 
435
452
  This works on **every** Android version - `onUserLeaveHint()` exists everywhere, and the platform's
436
453
  own switch never existed below Android 12.
@@ -439,9 +456,12 @@ The two PiP flags combine: auto-enter needs `pip.enabled` and `pip.autoEnterOnLe
439
456
  true.
440
457
 
441
458
 
442
- The Picture-in-Picture action row has three buttons: **Play/Pause**, **Expand** and **Close**.
443
- They arrive in JS as the `onPipPlayPause`, `onPipExpand` and `onPipClose` events, next to
444
- `onPipModeChanged`.
459
+ The Picture-in-Picture action row has **one** button: **Play/Pause**, with a state-driven icon
460
+ (the pause icon while the video is playing, the play icon while it is paused). The platform
461
+ renders its own expand / close / settings affordances next to it. The button reaches the engine
462
+ directly - no JavaScript in the path - so it works even when the JS bundle is not running. The
463
+ `onPipPlayPause` event still exists in the API for compatibility, next to `onPipModeChanged`, but
464
+ it is not what pauses playback.
445
465
 
446
466
  The media notification and lock screen are a separate surface. Its MediaSession advertises play,
447
467
  pause, play/pause, stop, skip-to-next, skip-to-previous and seek-to, with title, artist and album
@@ -543,15 +563,21 @@ before launching, and check `commands.isSurfaceMounted()`.
543
563
  **Picture-in-Picture does not start.** The Activity is missing
544
564
  `android:supportsPictureInPicture="true"` or `android:resizeableActivity="true"`. If auto-enter
545
565
  on leave does nothing, the Activity is not calling `MpvBridgeModule.notifyUserLeaveHint(this)`
546
- from `onUserLeaveHint()` - see [Picture-in-Picture](#picture-in-picture). If the log says the
547
- library refused the entry because no view carries your chrome `nativeID`, the `nativeID` in your
548
- config does not match the one on the view.
566
+ from `onUserLeaveHint()` - see [Picture-in-Picture](#picture-in-picture).
567
+
568
+ **The Picture-in-Picture window shows your app's chrome.** The platform crops your window to the
569
+ source rect hint in the COMMITTED PiP params, and the library commits them when the picture's
570
+ geometry, the video's shape or the playback state changes. If the crop is not happening, the
571
+ params are not being committed - the log says so (`companion.commitPipParams`). A `nativeID` in
572
+ your config that no view carries is NOT a refusal: the chrome is already hidden, and the library
573
+ says so in the log.
549
574
 
550
575
  **The Picture-in-Picture action row shows three buttons and none of them work.** That was the
551
576
  explicit-broadcast bug, fixed in 3.1.0: the action's PendingIntent named the receiver's
552
577
  component, and an explicit broadcast is resolved through the manifest, where the receiver was
553
578
  never declared. Check that you have not registered a receiver for the PiP actions yourself -
554
- this package registers one, and a second registration delivers every action twice.
579
+ this package registers one, and a second registration delivers every action twice. Since 3.3.0
580
+ the row carries ONE button (play/pause) and the platform renders its own expand / close.
555
581
 
556
582
 
557
583
  **Gradle fails with `libmpv.so not found at android/src/main/jniLibs/…`.** The postinstall