@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 +109 -27
- package/README.md +55 -29
- package/android/src/main/java/com/simba/player/PipManager.kt +141 -133
- package/android/src/main/java/com/simba/player/PipNativeEntry.kt +27 -5
- package/android/src/main/java/com/simba/player/mpv/MpvBridgeModule.kt +391 -121
- package/android/src/main/java/com/simba/player/mpv/MpvRenderView.kt +18 -1
- package/package.json +1 -1
- package/src/bridge/MpvPlayerModule.ts +15 -10
- package/src/types/config.ts +19 -15
|
@@ -189,12 +189,29 @@ class MpvRenderView(context: Context) : SurfaceView(context),
|
|
|
189
189
|
}
|
|
190
190
|
val location = IntArray(2)
|
|
191
191
|
getLocationInWindow(location)
|
|
192
|
-
|
|
192
|
+
val next = PictureFrame(
|
|
193
193
|
location[0],
|
|
194
194
|
location[1],
|
|
195
195
|
location[0] + width,
|
|
196
196
|
location[1] + height,
|
|
197
197
|
)
|
|
198
|
+
val previous = cachedWindowBounds
|
|
199
|
+
cachedWindowBounds = next
|
|
200
|
+
if (previous != null &&
|
|
201
|
+
previous.left == next.left &&
|
|
202
|
+
previous.top == next.top &&
|
|
203
|
+
previous.right == next.right &&
|
|
204
|
+
previous.bottom == next.bottom
|
|
205
|
+
) {
|
|
206
|
+
// The rect did not move, so the committed PiP params are still
|
|
207
|
+
// current. Layout passes are frequent, and re-committing the
|
|
208
|
+
// params on every one of them would be a binder call per frame.
|
|
209
|
+
return
|
|
210
|
+
}
|
|
211
|
+
// The rect moved, so the PiP params — which carry this rect as the
|
|
212
|
+
// source rect hint the platform crops the app's window to — are
|
|
213
|
+
// stale. The bridge re-commits them.
|
|
214
|
+
MpvBridgeModule.onPictureBoundsChanged()
|
|
198
215
|
}
|
|
199
216
|
|
|
200
217
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@simba-dev/react-native-media-player",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.3.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",
|
|
@@ -526,18 +526,23 @@ export interface MpvPlayerModuleBridge {
|
|
|
526
526
|
* returns it) and the caller needs it, because a caller that hides its
|
|
527
527
|
* chrome on a refused request has no way to bring it back.
|
|
528
528
|
*
|
|
529
|
-
* The ORDER still matters, and the reason is REACT, not the window
|
|
530
|
-
* Activity
|
|
531
|
-
*
|
|
532
|
-
*
|
|
533
|
-
*
|
|
534
|
-
*
|
|
535
|
-
*
|
|
529
|
+
* The ORDER still matters, and the reason is REACT, not the window. While
|
|
530
|
+
* the Activity is paused, the app window's UI layer stops producing frames,
|
|
531
|
+
* while a SurfaceView keeps compositing. What stops is REACT, in TWO ways:
|
|
532
|
+
* `FabricUIManager.onHostPause()` removes the DISPATCH_UI frame callback,
|
|
533
|
+
* so mount items are never applied to native views, and
|
|
534
|
+
* `JavaTimerManager.onHostPause()` freezes the timer registry, so
|
|
535
|
+
* `requestAnimationFrame` never fires. The JS runtime itself keeps running.
|
|
536
|
+
*
|
|
537
|
+
* So the chrome has to be unmounted BEFORE the window is asked for, and the
|
|
538
|
+
* consumer's own button is the only place where that is still possible:
|
|
539
|
+
* `onUserLeaveHint()` is called as part of the Activity's PAUSE
|
|
540
|
+
* transaction, and there is NO frame between it and the pause.
|
|
536
541
|
*
|
|
537
542
|
* This is the MANUAL path — the consumer's own button. The HOME path is
|
|
538
|
-
* the library's own: it
|
|
539
|
-
*
|
|
540
|
-
*
|
|
543
|
+
* the library's own: it enters PiP from `onUserLeaveHint()` (or lets the
|
|
544
|
+
* platform's own auto-enter switch do it on Android 12+), and hides the
|
|
545
|
+
* consumer's chrome from `onPictureInPictureModeChanged(true)`.
|
|
541
546
|
*/
|
|
542
547
|
enterPip(chapterTitle?: string | null, progressPct?: string | null): boolean;
|
|
543
548
|
/** Exit PiP by bringing the activity to the front. */
|
package/src/types/config.ts
CHANGED
|
@@ -56,26 +56,29 @@ export interface PipConfig {
|
|
|
56
56
|
* leaves the app (home, recents, app switcher).
|
|
57
57
|
*
|
|
58
58
|
* The entry happens in native code, inside the Activity's
|
|
59
|
-
* `onUserLeaveHint()`, because by then React Native has
|
|
60
|
-
*
|
|
61
|
-
*
|
|
59
|
+
* `onUserLeaveHint()`, because by then React Native has ALREADY frozen, in
|
|
60
|
+
* TWO ways: `FabricUIManager.onHostPause()` removes the DISPATCH_UI frame
|
|
61
|
+
* callback, so mount items are never applied to native views, and
|
|
62
|
+
* `JavaTimerManager.onHostPause()` freezes the timer registry, so
|
|
63
|
+
* `requestAnimationFrame` never fires. The JS runtime itself keeps running.
|
|
62
64
|
* Measured on emulator-5554 (API 37) on 2026-11-03: the JS handler ran
|
|
63
65
|
* immediately, the effect that would have driven the entry ran 5.7 s late,
|
|
64
66
|
* and the `requestAnimationFrame` never fired.
|
|
65
67
|
*
|
|
66
|
-
*
|
|
67
|
-
* (`PictureInPictureParams.Builder.setAutoEnterEnabled`)
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
68
|
+
* On Android 12+ the library also arms Android's own auto-enter switch
|
|
69
|
+
* (`PictureInPictureParams.Builder.setAutoEnterEnabled`), but ONLY while
|
|
70
|
+
* media is loaded — and it commits the PiP params to the Activity early,
|
|
71
|
+
* because the platform builds the PiP window from the LAST COMMITTED params
|
|
72
|
+
* and crops the app's window to their source rect hint. That crop is what
|
|
73
|
+
* keeps the app's chrome out of the PiP window.
|
|
74
|
+
*
|
|
75
|
+
* See the README's Picture-in-Picture section for how the two mechanisms
|
|
76
|
+
* fit together.
|
|
74
77
|
*/
|
|
75
78
|
autoEnterOnLeave: boolean;
|
|
76
79
|
/**
|
|
77
80
|
* The `nativeID` of the consumer's chrome root — the view the library hides
|
|
78
|
-
* natively when it enters PiP
|
|
81
|
+
* natively when it enters PiP.
|
|
79
82
|
*
|
|
80
83
|
* The literal belongs to the CONSUMER: the library stores it and uses it,
|
|
81
84
|
* and never hardcodes one of its own. Put the same string on the
|
|
@@ -84,9 +87,10 @@ export interface PipConfig {
|
|
|
84
87
|
* Omit it when the consumer draws no chrome of its own — then the library
|
|
85
88
|
* enters PiP without hiding anything.
|
|
86
89
|
*
|
|
87
|
-
* When it IS set and no view carries that `nativeID`, the
|
|
88
|
-
*
|
|
89
|
-
*
|
|
90
|
+
* When it IS set and no view carries that `nativeID`, the chrome is ALREADY
|
|
91
|
+
* gone — the consumer's own button path unmounts it in React before it asks
|
|
92
|
+
* for the window — so the library logs that and carries on. It never refuses
|
|
93
|
+
* the entry over a missing view.
|
|
90
94
|
*/
|
|
91
95
|
chromeNativeId?: string;
|
|
92
96
|
}
|