@simba-dev/react-native-media-player 3.3.1 → 3.3.2
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 +61 -0
- package/android/src/main/java/com/simba/player/PipManager.kt +15 -4
- package/android/src/main/java/com/simba/player/mpv/MpvBridgeModule.kt +77 -75
- package/android/src/main/java/com/simba/player/mpv/MpvRenderView.kt +2 -2
- package/package.json +1 -1
- package/src/types/config.ts +11 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,65 @@
|
|
|
1
1
|
|
|
2
|
+
## [3.3.2] - 2026-11-04
|
|
3
|
+
|
|
4
|
+
### Retracted
|
|
5
|
+
|
|
6
|
+
- **"The platform crops your window to the rect in `setSourceRectHint(...)`."** The 3.3.1
|
|
7
|
+
release retracted this claim in the README and in the CHANGELOG, but **four places in the
|
|
8
|
+
library's SOURCE still asserted it**, and one of them was in the TypeScript API docs every
|
|
9
|
+
consumer reads:
|
|
10
|
+
|
|
11
|
+
- `MpvBridgeModule.kt` — the docblock of `onPictureInPictureModeChanged` (*"Two mechanisms …
|
|
12
|
+
1. **The crop (primary).** The platform CROPS the app's window …"*), the docblock of
|
|
13
|
+
`pipSourceRectInWindow()` (*"The platform CROPS the app's window to that rect … which is
|
|
14
|
+
what keeps the app's chrome out of the PiP window"*), and an inline comment.
|
|
15
|
+
- `MpvRenderView.kt` — an inline comment.
|
|
16
|
+
- `src/types/config.ts` — the `autoEnterOnLeave` docblock, which also claimed that the library
|
|
17
|
+
*"arms Android's own auto-enter switch (`PictureInPictureParams.Builder
|
|
18
|
+
.setAutoEnterEnabled`), but ONLY while media is loaded"*. **That is false too**: the switch
|
|
19
|
+
is **not armed at all**, because the platform's auto-enter transitions the window through the
|
|
20
|
+
Shell transition and the app's hooks are never consulted.
|
|
21
|
+
|
|
22
|
+
All five now say what is true: `setSourceRectHint` is a **TRANSITION hint** — the region the
|
|
23
|
+
PiP window animates **from** — and the app's chrome is kept out by **hiding it before the
|
|
24
|
+
entry**, in native code.
|
|
25
|
+
|
|
26
|
+
**A retraction that leaves the wrong claim standing in the source is not a retraction.** The
|
|
27
|
+
claim is now pinned by a test (`PipSourceRectClaimTest`): no shipped file may assert the crop,
|
|
28
|
+
and a block that quotes the old claim has to say that it is false.
|
|
29
|
+
|
|
30
|
+
- **Two more stale prose claims, found by the same sweep.** The 3.3.1 release's own guard read
|
|
31
|
+
the library's **code** with the comments stripped, so a docblock that contradicted the code was
|
|
32
|
+
invisible to it. Two families survived into the published package:
|
|
33
|
+
|
|
34
|
+
- `MpvBridgeModule.kt` — the docblock of `isPlaying()` said *"Read from mpv's `playback-state`
|
|
35
|
+
at the moment of use"*. `playback-state` is **not an mpv property** — that is the whole reason
|
|
36
|
+
the PiP play/pause button was inert — so the docblock described a read that does not exist and
|
|
37
|
+
never did.
|
|
38
|
+
- `MpvBridgeModule.kt` and `PipManager.kt` — six places still described the library as **arming
|
|
39
|
+
the platform's auto-enter switch** *"only while media is loaded"*. The switch is not armed at
|
|
40
|
+
all; `autoEnter` is a **consumer policy** the library checks before it enters.
|
|
41
|
+
|
|
42
|
+
Both families are corrected, and both are now pinned by a test (`PiPFactClaimTest`).
|
|
43
|
+
|
|
44
|
+
### Added
|
|
45
|
+
|
|
46
|
+
- `PipSourceRectClaimTest` — a plain-JUnit guard (no device, no Robolectric, no network) that
|
|
47
|
+
fails if any source file, or the shipped README, asserts that the platform crops the app's
|
|
48
|
+
window. It also asserts that the scan **reaches** the files the claim lived in, because a
|
|
49
|
+
guard that silently covers nothing is not a guard.
|
|
50
|
+
- `PiPFactClaimTest` — the same shape for the other two PiP facts: no file may claim that the
|
|
51
|
+
library arms the platform's auto-enter switch, and no file may claim the playback state is read
|
|
52
|
+
from `playback-state`.
|
|
53
|
+
- `ClaimScan` — the shared scanner behind both, so a third guard does not have to re-implement
|
|
54
|
+
"what counts as a paragraph" and get it subtly different.
|
|
55
|
+
|
|
56
|
+
### Changed
|
|
57
|
+
|
|
58
|
+
- **Nothing behavioural.** 3.3.2 is a documentation-and-guard release: the runtime behaviour is
|
|
59
|
+
exactly 3.3.1's. If you are on 3.3.1, you do not need 3.3.1's successor for behaviour — but
|
|
60
|
+
3.3.1's README is the shipped documentation, and a false claim in it is a false claim in
|
|
61
|
+
every install.
|
|
62
|
+
|
|
2
63
|
## [3.3.1] - 2026-11-04
|
|
3
64
|
|
|
4
65
|
### Fixed
|
|
@@ -17,12 +17,21 @@ import androidx.annotation.RequiresApi
|
|
|
17
17
|
* Manages Android Picture-in-Picture (PiP) overlay actions and parameters
|
|
18
18
|
* for the `PlayerActivity` in `@simba/react-native-media-player`.
|
|
19
19
|
*
|
|
20
|
+
* v3.3.1:
|
|
21
|
+
* - ONE owner for the playback state: `PlaybackState`, which reads mpv's
|
|
22
|
+
* REAL properties (`idle-active`, `eof-reached`, `pause`)
|
|
23
|
+
* - The platform's own auto-enter switch is NOT armed - the app owns the
|
|
24
|
+
* entry, and the chrome is hidden IN THE ENTRY, before the window is
|
|
25
|
+
* asked for
|
|
26
|
+
* - The source-rect hint is a TRANSITION hint, not a crop - the crop
|
|
27
|
+
* claim is retracted
|
|
28
|
+
*
|
|
20
29
|
* v3.3.0:
|
|
21
30
|
* - ONE RemoteAction: [Play/Pause], with a state-driven icon
|
|
22
31
|
* - Notification text with chapter title + progress percentage (Android 12+)
|
|
23
32
|
* - No NEXT/PREV actions (removed for simplicity)
|
|
24
33
|
* - The platform's own auto-enter switch, armed only while media is loaded
|
|
25
|
-
* (Android 12+)
|
|
34
|
+
* (Android 12+) - RETRACTED in 3.3.1: the switch is not armed at all
|
|
26
35
|
*
|
|
27
36
|
* ## Who owns the action receiver
|
|
28
37
|
*
|
|
@@ -99,9 +108,11 @@ object PipManager {
|
|
|
99
108
|
* @param progressPercentage Percentage string like "45%" for notification text (Android 12+).
|
|
100
109
|
* @param playing Whether the video is playing right now — it picks
|
|
101
110
|
* the action's icon.
|
|
102
|
-
* @param autoEnter Whether the
|
|
103
|
-
* the user leaves the app
|
|
104
|
-
*
|
|
111
|
+
* @param autoEnter Whether the Activity may enter PiP by itself when
|
|
112
|
+
* the user leaves the app. This is a CONSUMER
|
|
113
|
+
* POLICY, checked by the library before it enters -
|
|
114
|
+
* it is NOT a platform switch, and the platform's
|
|
115
|
+
* own auto-enter switch is never armed.
|
|
105
116
|
*/
|
|
106
117
|
fun buildPipParams(
|
|
107
118
|
context: Context,
|
|
@@ -235,54 +235,41 @@ class MpvBridgeModule(reactContext: ReactApplicationContext) :
|
|
|
235
235
|
* Mirrors the companion sendEvent pattern from
|
|
236
236
|
* https://yor-dev.com/react-native-picture-in-picture-native-in-android/
|
|
237
237
|
*
|
|
238
|
-
* ## The chrome is hidden
|
|
239
|
-
*
|
|
240
|
-
*
|
|
241
|
-
*
|
|
242
|
-
*
|
|
243
|
-
*
|
|
244
|
-
*
|
|
245
|
-
* Measured on emulator-5554 (API 37) on 2026-11-
|
|
246
|
-
*
|
|
247
|
-
* PiP window
|
|
248
|
-
* down, with
|
|
249
|
-
*
|
|
250
|
-
*
|
|
251
|
-
*
|
|
252
|
-
*
|
|
253
|
-
*
|
|
254
|
-
*
|
|
255
|
-
*
|
|
256
|
-
*
|
|
257
|
-
*
|
|
258
|
-
*
|
|
259
|
-
*
|
|
260
|
-
*
|
|
261
|
-
*
|
|
262
|
-
*
|
|
263
|
-
*
|
|
264
|
-
*
|
|
265
|
-
*
|
|
266
|
-
*
|
|
267
|
-
*
|
|
268
|
-
*
|
|
269
|
-
*
|
|
270
|
-
*
|
|
271
|
-
*
|
|
272
|
-
*
|
|
273
|
-
* PAUSE transaction. There is NO frame between the hide and the
|
|
274
|
-
* pause, so a `visibility = View.GONE` applied there never reaches
|
|
275
|
-
* the pixels: the PiP window is built from the window's LAST
|
|
276
|
-
* RENDERED BUFFER, and that buffer still holds the chrome.
|
|
277
|
-
* Measured on emulator-5554 (API 37) on 2026-11-03: the native
|
|
278
|
-
* hide ran ~40 ms before the OS was asked for the window, and the
|
|
279
|
-
* PiP window still showed the app's full expanded chrome, scaled
|
|
280
|
-
* down, with dead buttons.
|
|
281
|
-
*
|
|
282
|
-
* By the time this callback runs, the platform HAS entered PiP and
|
|
283
|
-
* the Activity's window IS the PiP window — and the platform's own
|
|
284
|
-
* documentation says the activity is in a "paused, but rendering"
|
|
285
|
-
* state there, so an invalidation made now IS drawn.
|
|
238
|
+
* ## The chrome is hidden in the ENTRY, and this callback only restores it
|
|
239
|
+
*
|
|
240
|
+
* The chrome is hidden in `notifyUserLeaveHint(activity)` — the
|
|
241
|
+
* entry — BEFORE the window is asked for. That is the only moment a
|
|
242
|
+
* hide can reach the pixels: the PiP window IS the Activity's own
|
|
243
|
+
* window, and it shows that window's LAST RENDERED FRAME.
|
|
244
|
+
*
|
|
245
|
+
* Measured on emulator-5554 (API 37) on 2026-11-04: with the hide
|
|
246
|
+
* in `onPictureInPictureModeChanged(true)` — AFTER the platform had
|
|
247
|
+
* already transitioned the window — the PiP window showed the app's
|
|
248
|
+
* FULL expanded chrome, scaled down, with a frozen clock.
|
|
249
|
+
*
|
|
250
|
+
* So the hide here is a SECOND line of defence, not the mechanism:
|
|
251
|
+
* by the time this callback runs, the platform has already entered
|
|
252
|
+
* PiP and the window is already frozen.
|
|
253
|
+
*
|
|
254
|
+
* ## There is NO crop
|
|
255
|
+
*
|
|
256
|
+
* The 3.2.0 and 3.3.0 releases of this library claimed that the
|
|
257
|
+
* platform "CROPS the app's window to the rect in
|
|
258
|
+
* `setSourceRectHint(...)`" and that this crop is what keeps the
|
|
259
|
+
* app's chrome out of the PiP window. **That is false.**
|
|
260
|
+
* `setSourceRectHint` is a TRANSITION hint: it tells the platform
|
|
261
|
+
* which region of the window the PiP window should animate FROM.
|
|
262
|
+
* It does not crop anything. Measured on emulator-5554 (API 37) on
|
|
263
|
+
* 2026-11-04: with the hint committed, the PiP window showed the
|
|
264
|
+
* app's full chrome, scaled down.
|
|
265
|
+
*
|
|
266
|
+
* The chrome is kept out by HIDING it before the entry.
|
|
267
|
+
*
|
|
268
|
+
* ## Why the restore still happens here
|
|
269
|
+
*
|
|
270
|
+
* The chrome comes back when PiP ends, and it comes back EVEN IF
|
|
271
|
+
* the React instance is gone: the view is a native one, and the app
|
|
272
|
+
* is showing it (or not showing it) either way.
|
|
286
273
|
*
|
|
287
274
|
* @param newConfig the platform's new configuration. It is logged
|
|
288
275
|
* (it carries the PiP WINDOW's size in dp) and the work is
|
|
@@ -660,9 +647,12 @@ class MpvBridgeModule(reactContext: ReactApplicationContext) :
|
|
|
660
647
|
chapterTitle = chapterTitle ?: nativeTitle() ?: DEFAULT_PIP_TITLE,
|
|
661
648
|
progressPercentage = progressPct ?: nativeProgressPct() ?: DEFAULT_PIP_PROGRESS,
|
|
662
649
|
playing = isPlaying(),
|
|
663
|
-
//
|
|
664
|
-
//
|
|
665
|
-
//
|
|
650
|
+
// The CONSUMER'S POLICY: whether the Activity may enter PiP
|
|
651
|
+
// when the user leaves the app. It is checked by the library
|
|
652
|
+
// before it enters, and it is NOT a platform switch - the
|
|
653
|
+
// platform's own auto-enter switch is never armed, because
|
|
654
|
+
// the platform would transition the window before the app
|
|
655
|
+
// could hide its chrome.
|
|
666
656
|
autoEnter = isMediaLoaded(),
|
|
667
657
|
)
|
|
668
658
|
}
|
|
@@ -670,9 +660,10 @@ class MpvBridgeModule(reactContext: ReactApplicationContext) :
|
|
|
670
660
|
/**
|
|
671
661
|
* Whether the engine is playing right now.
|
|
672
662
|
*
|
|
673
|
-
* Read from mpv's `
|
|
674
|
-
*
|
|
675
|
-
* the app is paused and no
|
|
663
|
+
* Read from mpv's REAL properties (`idle-active`, `eof-reached`,
|
|
664
|
+
* `pause`) at the moment of use, and never from a JS flag: the PiP
|
|
665
|
+
* action's icon has to be true even when the app is paused and no
|
|
666
|
+
* JS is running.
|
|
676
667
|
*/
|
|
677
668
|
private fun isPlaying(): Boolean {
|
|
678
669
|
// ONE owner: `PlaybackState`, which reads mpv's REAL
|
|
@@ -760,10 +751,11 @@ class MpvBridgeModule(reactContext: ReactApplicationContext) :
|
|
|
760
751
|
* Whether mpv currently has media loaded.
|
|
761
752
|
*
|
|
762
753
|
* Read live through [PlaybackHost] — never from a JS flag, which
|
|
763
|
-
* can be stale by the time the user presses HOME. The question
|
|
764
|
-
*
|
|
765
|
-
*
|
|
766
|
-
* `
|
|
754
|
+
* can be stale by the time the user presses HOME. The question is
|
|
755
|
+
* answered by mpv's REAL properties (`idle-active`, `eof-reached`,
|
|
756
|
+
* `pause`), and the vocabulary is the one the library has always
|
|
757
|
+
* published: `idle` and `stopped` mean no media, and `paused` and
|
|
758
|
+
* `playing` mean something is still loaded.
|
|
767
759
|
*/
|
|
768
760
|
private fun isMediaLoaded(): Boolean {
|
|
769
761
|
// ONE owner: `PlaybackState`, which reads mpv's REAL
|
|
@@ -854,15 +846,25 @@ class MpvBridgeModule(reactContext: ReactApplicationContext) :
|
|
|
854
846
|
* ## What the rect is, and what the platform does with it
|
|
855
847
|
*
|
|
856
848
|
* Android's `setSourceRectHint` wants the region of the window where
|
|
857
|
-
* the video is
|
|
858
|
-
*
|
|
859
|
-
*
|
|
860
|
-
*
|
|
849
|
+
* the video is, so the PiP window can ANIMATE FROM the picture
|
|
850
|
+
* instead of from a black rectangle.
|
|
851
|
+
*
|
|
852
|
+
* **It does NOT crop the app's window.** The 3.2.0 and 3.3.0
|
|
853
|
+
* releases of this library claimed it did, and that the crop is
|
|
854
|
+
* what keeps the app's chrome out of the PiP window. That claim is
|
|
855
|
+
* false and is retracted in 3.3.2: `setSourceRectHint` is a
|
|
856
|
+
* TRANSITION hint — the region the PiP window animates FROM — and
|
|
857
|
+
* nothing more. Measured on emulator-5554 (API 37) on 2026-11-04:
|
|
858
|
+
* with the hint committed, the PiP window showed the app's FULL
|
|
859
|
+
* chrome, scaled down.
|
|
860
|
+
*
|
|
861
|
+
* The chrome is kept out by HIDING it before the entry, in native
|
|
862
|
+
* code — see `notifyUserLeaveHint(activity)`.
|
|
861
863
|
*
|
|
862
864
|
* It is **not** the picture view's box. The picture fills its lane
|
|
863
|
-
* (`StyleSheet.absoluteFill`), so the view's rect is the whole window
|
|
864
|
-
* and hinting that would
|
|
865
|
-
*
|
|
865
|
+
* (`StyleSheet.absoluteFill`), so the view's rect is the whole window
|
|
866
|
+
* — and hinting that would animate the PiP window out of the whole
|
|
867
|
+
* screen rather than out of the picture. The rect has to be the
|
|
866
868
|
* video's FRAME inside the view: the largest rect of the video's own
|
|
867
869
|
* shape that fits inside it, or the whole view when the picture is
|
|
868
870
|
* filling it.
|
|
@@ -1477,9 +1479,10 @@ class MpvBridgeModule(reactContext: ReactApplicationContext) :
|
|
|
1477
1479
|
ensurePtr()
|
|
1478
1480
|
Log.i(TAG, "[PlaybackTrace][Bridge][stop] ptr=$nativePtr")
|
|
1479
1481
|
MPVLib.nativeStop(nativePtr)
|
|
1480
|
-
// A stopped session has no media, so the
|
|
1481
|
-
//
|
|
1482
|
-
//
|
|
1482
|
+
// A stopped session has no media, so the entry is refused: the
|
|
1483
|
+
// library must not throw the user into a PiP window of a stopped
|
|
1484
|
+
// session. The platform's own auto-enter switch is not armed at
|
|
1485
|
+
// all, so there is no platform path to a PiP window either.
|
|
1483
1486
|
onPlaybackStateChanged()
|
|
1484
1487
|
}
|
|
1485
1488
|
|
|
@@ -3040,12 +3043,11 @@ class MpvBridgeModule(reactContext: ReactApplicationContext) :
|
|
|
3040
3043
|
pipAutoEnter = desired
|
|
3041
3044
|
// The policy is remembered so `notifyUserLeaveHint(activity)`
|
|
3042
3045
|
// knows whether to enter PiP at all. The platform's OWN
|
|
3043
|
-
// auto-enter switch is NOT armed: the
|
|
3044
|
-
//
|
|
3045
|
-
//
|
|
3046
|
-
//
|
|
3047
|
-
//
|
|
3048
|
-
// measurement.
|
|
3046
|
+
// auto-enter switch is NOT armed: the platform transitions the
|
|
3047
|
+
// window through the Shell transition and the app's hooks are
|
|
3048
|
+
// never consulted, so the chrome would still be mounted when
|
|
3049
|
+
// the window was captured - dead and scaled down. See
|
|
3050
|
+
// `PipManager.buildPipParams` for the measurement.
|
|
3049
3051
|
pipAutoEnterForCompanion = desired
|
|
3050
3052
|
} catch (t: Throwable) {
|
|
3051
3053
|
// Never let this reject the `setConfig` promise: the config
|
|
@@ -3135,7 +3137,7 @@ class MpvBridgeModule(reactContext: ReactApplicationContext) :
|
|
|
3135
3137
|
// while the Activity is paused.
|
|
3136
3138
|
rememberPipActivity(activity)
|
|
3137
3139
|
// The params are committed BEFORE the window is requested, so the
|
|
3138
|
-
// platform has the source rect hint it
|
|
3140
|
+
// platform has the source rect hint it ANIMATES FROM.
|
|
3139
3141
|
commitPipParams(activity)
|
|
3140
3142
|
// The params are built and the window is requested by the
|
|
3141
3143
|
// companion's ONE builder - the same one the native HOME path
|
|
@@ -209,8 +209,8 @@ class MpvRenderView(context: Context) : SurfaceView(context),
|
|
|
209
209
|
return
|
|
210
210
|
}
|
|
211
211
|
// The rect moved, so the PiP params — which carry this rect as the
|
|
212
|
-
// source rect hint the
|
|
213
|
-
//
|
|
212
|
+
// source rect hint the PiP window ANIMATES FROM — are stale. The
|
|
213
|
+
// bridge re-commits them.
|
|
214
214
|
MpvBridgeModule.onPictureBoundsChanged()
|
|
215
215
|
}
|
|
216
216
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@simba-dev/react-native-media-player",
|
|
3
|
-
"version": "3.3.
|
|
3
|
+
"version": "3.3.2",
|
|
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",
|
package/src/types/config.ts
CHANGED
|
@@ -65,15 +65,18 @@ export interface PipConfig {
|
|
|
65
65
|
* immediately, the effect that would have driven the entry ran 5.7 s late,
|
|
66
66
|
* and the `requestAnimationFrame` never fired.
|
|
67
67
|
*
|
|
68
|
-
* On Android 12+ the library
|
|
69
|
-
* (`PictureInPictureParams.Builder.setAutoEnterEnabled`)
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
68
|
+
* On Android 12+ the library does **NOT** arm Android's own auto-enter
|
|
69
|
+
* switch (`PictureInPictureParams.Builder.setAutoEnterEnabled`): the
|
|
70
|
+
* platform's auto-enter transitions the window through the Shell
|
|
71
|
+
* transition, the app's hooks are never consulted, and the app's chrome
|
|
72
|
+
* ends up in the PiP window. The app owns the entry instead — see the
|
|
73
|
+
* README's Picture-in-Picture section.
|
|
74
74
|
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
75
|
+
* The library commits the PiP params to the Activity early, because the
|
|
76
|
+
* platform builds the PiP window from the LAST COMMITTED params. The
|
|
77
|
+
* source rect hint among them is a TRANSITION hint — the region the PiP
|
|
78
|
+
* window ANIMATES FROM — not a crop. The app's chrome is kept out of the
|
|
79
|
+
* PiP window by hiding it before the entry, in native code.
|
|
77
80
|
*/
|
|
78
81
|
autoEnterOnLeave: boolean;
|
|
79
82
|
/**
|