@simba-dev/react-native-media-player 3.0.5 → 3.2.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 +161 -6
- package/README.md +114 -19
- package/android/src/main/java/com/simba/player/PipManager.kt +147 -33
- package/android/src/main/java/com/simba/player/PipNativeEntry.kt +86 -0
- package/android/src/main/java/com/simba/player/mpv/MpvBridgeModule.kt +478 -218
- package/package.json +1 -1
- package/src/bridge/MpvPlayerModule.ts +20 -22
- package/src/types/config.ts +32 -7
- package/src/types/player.ts +0 -1
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.2.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",
|
|
@@ -113,14 +113,12 @@ export interface LaunchParams {
|
|
|
113
113
|
}
|
|
114
114
|
|
|
115
115
|
/**
|
|
116
|
-
* All
|
|
116
|
+
* All 26 events emitted by the Kotlin bridge.
|
|
117
117
|
*
|
|
118
|
-
*
|
|
119
|
-
*
|
|
120
|
-
*
|
|
121
|
-
*
|
|
122
|
-
* `PipManager`'s note on why the OS-initiated transition cannot be used
|
|
123
|
-
* for that.
|
|
118
|
+
* The HOME path is NOT one of them. The library enters Picture-in-Picture
|
|
119
|
+
* itself on that path (see `pip.autoEnterOnLeave`), so there is no "the
|
|
120
|
+
* user is leaving" event for a consumer to react to — the event's only
|
|
121
|
+
* consumer was the JS-driven entry the library took over.
|
|
124
122
|
*/
|
|
125
123
|
export type PlayerEventName =
|
|
126
124
|
| 'onFileLoaded'
|
|
@@ -148,8 +146,7 @@ export type PlayerEventName =
|
|
|
148
146
|
| 'onPipModeChanged'
|
|
149
147
|
| 'onPipPlayPause'
|
|
150
148
|
| 'onPipExpand'
|
|
151
|
-
| 'onPipClose'
|
|
152
|
-
| 'onUserLeaveHint';
|
|
149
|
+
| 'onPipClose';
|
|
153
150
|
|
|
154
151
|
/** Typed payload map for each event. */
|
|
155
152
|
export interface PlayerEventPayloads {
|
|
@@ -208,17 +205,6 @@ export interface PlayerEventPayloads {
|
|
|
208
205
|
onPipPlayPause: Record<string, never>;
|
|
209
206
|
onPipExpand: Record<string, never>;
|
|
210
207
|
onPipClose: Record<string, never>;
|
|
211
|
-
/**
|
|
212
|
-
* The user is leaving the app (home, recents, app switcher).
|
|
213
|
-
*
|
|
214
|
-
* A consumer that owns its own chrome over the picture uses this to
|
|
215
|
-
* remove that chrome and THEN enter Picture-in-Picture itself. The
|
|
216
|
-
* order is not negotiable: an Activity in PiP does not redraw, so
|
|
217
|
-
* whatever its window contained at the moment of the transition is
|
|
218
|
-
* what the PiP window keeps showing — frozen, dead and scaled down.
|
|
219
|
-
* See `PipManager`'s note on the same thing.
|
|
220
|
-
*/
|
|
221
|
-
onUserLeaveHint: Record<string, never>;
|
|
222
208
|
}
|
|
223
209
|
|
|
224
210
|
// ═══════════════════════════════════════════════════════════════════════════
|
|
@@ -539,6 +525,19 @@ export interface MpvPlayerModuleBridge {
|
|
|
539
525
|
* happen — the native side has the answer (`enterPictureInPictureMode`
|
|
540
526
|
* returns it) and the caller needs it, because a caller that hides its
|
|
541
527
|
* chrome on a refused request has no way to bring it back.
|
|
528
|
+
*
|
|
529
|
+
* The ORDER still matters, and the reason is REACT, not the window: an
|
|
530
|
+
* Activity in Picture-in-Picture is "paused, but rendering" (AOSP), so the
|
|
531
|
+
* PiP window keeps whatever the Activity's window held at the transition —
|
|
532
|
+
* but React Native pauses the React scheduler with the Activity, so a
|
|
533
|
+
* React commit cannot land and no frame is produced. Chrome that is still
|
|
534
|
+
* mounted at that moment therefore stays in the PiP window, dead and
|
|
535
|
+
* scaled down.
|
|
536
|
+
*
|
|
537
|
+
* This is the MANUAL path — the consumer's own button. The HOME path is
|
|
538
|
+
* the library's own: it hides the consumer's chrome natively, inside
|
|
539
|
+
* `onUserLeaveHint()`, and enters PiP from there, because by then no React
|
|
540
|
+
* commit can land at all.
|
|
542
541
|
*/
|
|
543
542
|
enterPip(chapterTitle?: string | null, progressPct?: string | null): boolean;
|
|
544
543
|
/** Exit PiP by bringing the activity to the front. */
|
|
@@ -1075,7 +1074,7 @@ export function removeAllListeners(event?: PlayerEventName): void {
|
|
|
1075
1074
|
}
|
|
1076
1075
|
|
|
1077
1076
|
/**
|
|
1078
|
-
* All
|
|
1077
|
+
* All 26 player event names — the ONE owner of this list.
|
|
1079
1078
|
*
|
|
1080
1079
|
* `<PlayerProvider>` imports it to subscribe to every event on mount,
|
|
1081
1080
|
* `removeAllListeners()` iterates it when no event is named, and the
|
|
@@ -1109,5 +1108,4 @@ export const ALL_PLAYER_EVENTS: readonly PlayerEventName[] = [
|
|
|
1109
1108
|
'onPipPlayPause',
|
|
1110
1109
|
'onPipExpand',
|
|
1111
1110
|
'onPipClose',
|
|
1112
|
-
'onUserLeaveHint',
|
|
1113
1111
|
];
|
package/src/types/config.ts
CHANGED
|
@@ -52,18 +52,43 @@ export interface PipConfig {
|
|
|
52
52
|
/** Master switch — when false, all PiP entry requests are ignored. */
|
|
53
53
|
enabled: boolean;
|
|
54
54
|
/**
|
|
55
|
-
* When true, the library
|
|
56
|
-
* the
|
|
55
|
+
* When true, the library enters Picture-in-Picture ITSELF when the user
|
|
56
|
+
* leaves the app (home, recents, app switcher).
|
|
57
|
+
*
|
|
58
|
+
* The entry happens in native code, inside the Activity's
|
|
59
|
+
* `onUserLeaveHint()`, because by then React Native has already paused the
|
|
60
|
+
* React scheduler with the Activity: a React commit cannot land and there
|
|
61
|
+
* is no frame clock, so a JS-driven entry cannot hide anything in time.
|
|
62
|
+
* Measured on emulator-5554 (API 37) on 2026-11-03: the JS handler ran
|
|
63
|
+
* immediately, the effect that would have driven the entry ran 5.7 s late,
|
|
64
|
+
* and the `requestAnimationFrame` never fired.
|
|
57
65
|
*
|
|
58
66
|
* The library deliberately does NOT arm Android's own auto-enter switch
|
|
59
67
|
* (`PictureInPictureParams.Builder.setAutoEnterEnabled`): that makes the OS
|
|
60
|
-
* transition the Activity
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
*
|
|
68
|
+
* transition the Activity with no chance to remove the app's own chrome. An
|
|
69
|
+
* Activity in Picture-in-Picture is "paused, but rendering" — what stops is
|
|
70
|
+
* REACT, not the window — so chrome that is still mounted when the
|
|
71
|
+
* transition happens stays in the PiP window, dead and scaled down. See the
|
|
72
|
+
* README's Picture-in-Picture section for the two lines of Kotlin that go
|
|
73
|
+
* with it.
|
|
65
74
|
*/
|
|
66
75
|
autoEnterOnLeave: boolean;
|
|
76
|
+
/**
|
|
77
|
+
* The `nativeID` of the consumer's chrome root — the view the library hides
|
|
78
|
+
* natively when it enters PiP on the HOME path.
|
|
79
|
+
*
|
|
80
|
+
* The literal belongs to the CONSUMER: the library stores it and uses it,
|
|
81
|
+
* and never hardcodes one of its own. Put the same string on the
|
|
82
|
+
* consumer's chrome `<View nativeID="...">`.
|
|
83
|
+
*
|
|
84
|
+
* Omit it when the consumer draws no chrome of its own — then the library
|
|
85
|
+
* enters PiP without hiding anything.
|
|
86
|
+
*
|
|
87
|
+
* When it IS set and no view carries that `nativeID`, the library REFUSES
|
|
88
|
+
* the entry and logs a warning naming the id: entering PiP with the chrome
|
|
89
|
+
* still mounted paints the app's dead chrome into the PiP window.
|
|
90
|
+
*/
|
|
91
|
+
chromeNativeId?: string;
|
|
67
92
|
}
|
|
68
93
|
|
|
69
94
|
/** Audio playback configuration. */
|
package/src/types/player.ts
CHANGED
|
@@ -1479,7 +1479,6 @@ export function applyPlayerEvent(
|
|
|
1479
1479
|
case 'onPipPlayPause':
|
|
1480
1480
|
case 'onPipExpand':
|
|
1481
1481
|
case 'onPipClose':
|
|
1482
|
-
case 'onUserLeaveHint':
|
|
1483
1482
|
// No state-field mapping for these in the V13 surface (PiP state
|
|
1484
1483
|
// is owned by the activity; reconfig signals a video-parameter
|
|
1485
1484
|
// change that's already covered by onVideoParamsChanged).
|