@simba-dev/react-native-media-player 3.2.0 → 3.3.1
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 +163 -27
- package/README.md +92 -29
- package/android/src/main/java/com/simba/player/PipManager.kt +157 -134
- package/android/src/main/java/com/simba/player/PipNativeEntry.kt +9 -5
- package/android/src/main/java/com/simba/player/mpv/MpvBridgeModule.kt +422 -156
- package/android/src/main/java/com/simba/player/mpv/MpvRenderView.kt +18 -1
- package/android/src/main/java/com/simba/player/mpv/PlaybackState.kt +174 -0
- package/package.json +1 -1
- package/src/bridge/MpvPlayerModule.ts +15 -10
- package/src/types/config.ts +19 -15
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,142 @@
|
|
|
1
1
|
|
|
2
|
+
## [3.3.1] - 2026-11-04
|
|
3
|
+
|
|
4
|
+
### Fixed
|
|
5
|
+
|
|
6
|
+
- **The Picture-in-Picture play/pause button did nothing.** The action reached the library's
|
|
7
|
+
receiver, the receiver logged "play/pause: played", and the picture kept moving: the button
|
|
8
|
+
looked alive and did nothing. Measured on emulator-5554 (API 37) on 2026-11-04.
|
|
9
|
+
|
|
10
|
+
The cause was that the receiver read mpv's `playback-state` — **a property mpv does not
|
|
11
|
+
have**. It is absent from mpv's own manuals (`DOCS/man/options.rst`, `DOCS/man/mpv.rst`) and
|
|
12
|
+
from mpv's source (`player/command.c`: `"playback-state"` appears ZERO times, while
|
|
13
|
+
`"idle-active"`, `"eof-reached"`, `"pause"` and `"playback-time"` all appear). The read
|
|
14
|
+
failed, the native helper returned the JSON literal `null`, and "null" is neither "play" nor
|
|
15
|
+
"idle" — so every answer was wrong in the same direction: the receiver always believed the
|
|
16
|
+
video was stopped and called PLAY on an already-playing video.
|
|
17
|
+
|
|
18
|
+
The same broken read was in three other places — the PiP action's icon, the library's own
|
|
19
|
+
media check, and the consumer app's media check — so "media is loaded" was true for every
|
|
20
|
+
value. All four now go through **one** owner, `PlaybackState`, which reads mpv's real
|
|
21
|
+
properties and derives the same vocabulary the library has always published:
|
|
22
|
+
`idle` / `stopped` / `paused` / `playing`.
|
|
23
|
+
|
|
24
|
+
- **The Picture-in-Picture window showed the app's full chrome on the HOME path.** The platform
|
|
25
|
+
transitions the window itself when the auto-enter switch is armed, and it does that through
|
|
26
|
+
the Shell transition: the app's hooks are never consulted. `Activity.onUserLeaveHint()` did
|
|
27
|
+
**not fire at all** on a HOME press (measured on emulator-5554, API 37, 2026-11-04 — zero log
|
|
28
|
+
lines) and the PiP window showed the app's full expanded chrome, scaled down.
|
|
29
|
+
|
|
30
|
+
The entry now runs from `Activity.onPictureInPictureRequested()` — AOSP's own PiP entry hook —
|
|
31
|
+
which is called while the Activity is still **RESUMED**. That matters twice over:
|
|
32
|
+
`Activity.enterPictureInPictureMode()` throws `IllegalStateException` unless the Activity is
|
|
33
|
+
resumed, and the app is still drawing, so the chrome-less window is presented before the
|
|
34
|
+
platform transitions it. The chrome is now hidden **in the entry, before the window is asked
|
|
35
|
+
for** — hiding it afterwards, from `onPictureInPictureModeChanged(true)`, was too late.
|
|
36
|
+
|
|
37
|
+
The platform's auto-enter switch is **not armed**. With it armed there is no pre-transition
|
|
38
|
+
hook to use, and ATMS refuses an explicit entry while it is enabled ("auto-enter should take
|
|
39
|
+
in place instead").
|
|
40
|
+
|
|
41
|
+
### Retracted
|
|
42
|
+
|
|
43
|
+
- **"The platform crops your window to the rect in `setSourceRectHint(...)`."** This was
|
|
44
|
+
published in the 3.2.0 and 3.3.0 READMEs and CHANGELOGs, and it is **false**.
|
|
45
|
+
`setSourceRectHint` is a **transition hint**: it tells the platform which region of your window
|
|
46
|
+
the PiP window should animate FROM. It does not crop anything. Measured on emulator-5554 (API
|
|
47
|
+
37) on 2026-11-04: with the hint committed, the PiP window showed the app's **full** chrome,
|
|
48
|
+
scaled down. The chrome is kept out by hiding it before the entry, not by a crop.
|
|
49
|
+
|
|
50
|
+
## [3.3.0] - 2026-11-04
|
|
51
|
+
|
|
52
|
+
### Fixed
|
|
53
|
+
|
|
54
|
+
- **The Picture-in-Picture window showed the app's full expanded chrome, scaled down.** The PiP
|
|
55
|
+
window opened, and the video played under it — but the header band, the scrub row with its frozen
|
|
56
|
+
clock, the ±10 buttons, the big pause button and the volume row were painted into the window
|
|
57
|
+
too, at a fraction of their size, and their buttons were dead. Measured on emulator-5554 (API
|
|
58
|
+
37) on 2026-11-03.
|
|
59
|
+
|
|
60
|
+
**3.2.0's claim is retracted.** 3.2.0 said the library hides the consumer's chrome on the HOME
|
|
61
|
+
path. It did hide it — natively, with `visibility = View.GONE` — but the hide **could not reach
|
|
62
|
+
the pixels**: `Activity.onUserLeaveHint()` is called as part of the Activity's PAUSE
|
|
63
|
+
transaction, and there is **no frame between the hide and the pause**. The PiP window is built
|
|
64
|
+
from the window's last rendered buffer, and that buffer still held the chrome. The chrome was
|
|
65
|
+
hidden and stayed visible.
|
|
66
|
+
|
|
67
|
+
**3.3.0's own claim is retracted by 3.3.1.** The crop mechanism described below is NOT a
|
|
68
|
+
mechanism: `setSourceRectHint` is a transition hint, not a crop, and the device disproved it.
|
|
69
|
+
3.3.1 replaces this whole mechanism with hiding the chrome before the entry, from
|
|
70
|
+
`Activity.onPictureInPictureRequested()`. The text below is kept as the historical record of
|
|
71
|
+
what 3.3.0 believed, and it is WRONG.
|
|
72
|
+
|
|
73
|
+
Two mechanisms keep the app's chrome out of the PiP window now, and they are layered:
|
|
74
|
+
|
|
75
|
+
1. **The crop (primary).** The platform crops the app's window to the rect in
|
|
76
|
+
`PictureInPictureParams.setSourceRectHint(...)` and scales that crop into the PiP window. The
|
|
77
|
+
library now **commits** the params to the Activity with
|
|
78
|
+
`Activity.setPictureInPictureParams(...)` — early, and every time the picture's geometry,
|
|
79
|
+
the video's shape or the playback state changes — instead of handing them over only at the
|
|
80
|
+
entry moment. A source rect hint that is only handed over at the entry moment never crops
|
|
81
|
+
anything: the PiP window then shows the whole window, scaled down. Google's own
|
|
82
|
+
`androidx.core-pip` does exactly this — it tracks the player view's bounds and commits the
|
|
83
|
+
params as they change.
|
|
84
|
+
|
|
85
|
+
The hint is the region of the window the **video** occupies (the video's own frame inside
|
|
86
|
+
the picture box, letterboxed), not the picture box's rect — the box fills the screen, so
|
|
87
|
+
hinting the box crops the whole screen into the PiP window, chrome included.
|
|
88
|
+
|
|
89
|
+
2. **The hide (second line of defence).** The chrome the app draws *over* the video — the big
|
|
90
|
+
pause button, the scrub row — is inside the crop, so the crop cannot remove it. It is now
|
|
91
|
+
hidden from `onPictureInPictureModeChanged(true)`: after the platform has entered PiP, and
|
|
92
|
+
while the activity is "paused, but rendering", so the invalidation is drawn. A `nativeID`
|
|
93
|
+
that no view carries is no longer a refusal — it means the chrome is **already hidden**, and
|
|
94
|
+
the entry goes on.
|
|
95
|
+
|
|
96
|
+
- **The PiP action row was a second copy of the platform's own buttons.** The library's Expand
|
|
97
|
+
and Close actions are gone: the platform renders its own expand / close / settings affordances
|
|
98
|
+
in the PiP window, and the library's row duplicated them. The row now carries **exactly one**
|
|
99
|
+
action, play/pause, with a **state-driven icon** — the pause icon while the video is playing,
|
|
100
|
+
the play icon while it is paused — and the params are re-committed when the playback state
|
|
101
|
+
changes so the platform picks the new icon up.
|
|
102
|
+
|
|
103
|
+
- **The play/pause button went through JavaScript to pause the video.** The broadcast now
|
|
104
|
+
reaches the engine directly (`PlaybackHost` + `MPVLib`), the same way
|
|
105
|
+
`MediaPlaybackService`'s session callbacks drive playback. The old path was
|
|
106
|
+
broadcast → JS event → bridge → mpv, and this library's own code recorded why that shape is
|
|
107
|
+
fragile: "the broadcast can arrive after the JS bundle has unloaded". The `onPipPlayPause`
|
|
108
|
+
event still exists in the JS API for compatibility, but it is not the mechanism that pauses
|
|
109
|
+
playback.
|
|
110
|
+
|
|
111
|
+
- **The source rect hint was applied from Android 12 only.** `setSourceRectHint(Rect)` has been
|
|
112
|
+
available since API 26; react-native-video and expo-video both hand it over from API 26.
|
|
113
|
+
|
|
114
|
+
### Changed
|
|
115
|
+
|
|
116
|
+
- **Android 12+ uses the platform's own auto-enter switch.** The library arms
|
|
117
|
+
`setAutoEnterEnabled(true)` — but **only while media is loaded**, and disarms it when playback
|
|
118
|
+
stops, so browsing the Home screen with nothing playing cannot throw the user into a PiP
|
|
119
|
+
window. While auto-enter is armed, `notifyUserLeaveHint(activity)` is a logged no-op: ATMS
|
|
120
|
+
refuses an explicit `enterPictureInPictureMode()` while auto-enter is enabled ("auto-enter
|
|
121
|
+
should take in place instead"). The explicit entry is kept for API 24–30. The consumer's
|
|
122
|
+
Activity keeps calling `MpvBridgeModule.notifyUserLeaveHint(this)` from `onUserLeaveHint()` —
|
|
123
|
+
unchanged, and correct on every API level.
|
|
124
|
+
|
|
125
|
+
### Documentation
|
|
126
|
+
|
|
127
|
+
- Every sentence in this library that said React Native pauses its own scheduler together with the
|
|
128
|
+
Activity was **mechanically wrong**, and a wrong reason sends the next reader looking for the
|
|
129
|
+
fix in the wrong place. React Native freezes in **two** ways while the Activity is paused:
|
|
130
|
+
`FabricUIManager.onHostPause()` removes the DISPATCH_UI frame callback, so mount items are
|
|
131
|
+
never applied to native views, and `JavaTimerManager.onHostPause()` freezes the timer registry,
|
|
132
|
+
so `requestAnimationFrame` never fires. The JS runtime itself keeps running. Corrected in
|
|
133
|
+
`MpvBridgeModule.kt`, `PipManager.kt`, `PipNativeEntry.kt`, `MpvPlayerModule.ts` and
|
|
134
|
+
`config.ts`.
|
|
135
|
+
|
|
136
|
+
- The claim that an Activity in Picture-in-Picture never repaints its window was corrected too:
|
|
137
|
+
the app window's **UI layer** stops producing frames while it is paused, while a `SurfaceView`
|
|
138
|
+
keeps compositing.
|
|
139
|
+
|
|
2
140
|
## [3.2.0] - 2026-11-03
|
|
3
141
|
|
|
4
142
|
### Fixed
|
|
@@ -11,18 +149,21 @@
|
|
|
11
149
|
|
|
12
150
|
The cause was measured, not guessed. `Activity.onUserLeaveHint()` fired and the JS handler ran
|
|
13
151
|
immediately, but the effect that would have driven the entry ran **5.7 s late** and the
|
|
14
|
-
`requestAnimationFrame` **never fired**. React Native
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
`
|
|
152
|
+
`requestAnimationFrame` **never fired**. React Native freezes in TWO ways while the Activity is
|
|
153
|
+
paused — `FabricUIManager.onHostPause()` removes the DISPATCH_UI frame callback, so mount items
|
|
154
|
+
are never applied to native views, and `JavaTimerManager.onHostPause()` freezes the timer
|
|
155
|
+
registry, so `requestAnimationFrame` never fires. The entry therefore has to be **native**,
|
|
156
|
+
inside `onUserLeaveHint()`, before `onPause`.
|
|
18
157
|
|
|
19
158
|
The library now performs the HOME-path entry itself:
|
|
20
159
|
|
|
21
|
-
- the
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
160
|
+
- the PiP parameters are built by the same builder the JS path uses, and handed to the platform;
|
|
161
|
+
- the chrome is restored when Picture-in-Picture ends.
|
|
162
|
+
|
|
163
|
+
> **Superseded by 3.3.0.** This release made the PiP window **open** — it did not make the
|
|
164
|
+
> chrome go away. The chrome hide it added could not reach the pixels (there is no frame
|
|
165
|
+
> between the hide and the pause), and the source rect hint it passed at the entry moment never
|
|
166
|
+
> cropped the window. See the 3.3.0 entry above for what actually fixed it.
|
|
26
167
|
|
|
27
168
|
**Action required:** your Activity has to hand over the Activity.
|
|
28
169
|
|
|
@@ -49,10 +190,7 @@
|
|
|
49
190
|
|
|
50
191
|
The `nativeID` literal belongs to the consumer; the library never hardcodes one of its own.
|
|
51
192
|
Omit `chromeNativeId` if your app draws no chrome of its own — the library then enters
|
|
52
|
-
Picture-in-Picture without hiding anything.
|
|
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.
|
|
193
|
+
Picture-in-Picture without hiding anything.
|
|
56
194
|
|
|
57
195
|
### Removed
|
|
58
196
|
|
|
@@ -70,8 +208,7 @@
|
|
|
70
208
|
|
|
71
209
|
- `MpvBridgeModule.notifyUserLeaveHint()` is now
|
|
72
210
|
`notifyUserLeaveHint(activity: Activity): Boolean`. It takes the Activity — the entry happens
|
|
73
|
-
on it
|
|
74
|
-
`true` when the Activity entered Picture-in-Picture.
|
|
211
|
+
on it — and returns the OS's own answer: `true` when the Activity entered Picture-in-Picture.
|
|
75
212
|
- **The PiP parameters have ONE owner.** The JS path (`enterPip`) and the native path
|
|
76
213
|
(`notifyUserLeaveHint`) build them through the same function, so the two cannot drift apart.
|
|
77
214
|
- The native path reports the title from mpv's `media-title` — which IS the title the consumer
|
|
@@ -80,14 +217,13 @@
|
|
|
80
217
|
|
|
81
218
|
### Documentation
|
|
82
219
|
|
|
83
|
-
- Five places in this library still carried the false claim that
|
|
84
|
-
Picture
|
|
85
|
-
**
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
`config.ts`.
|
|
220
|
+
- Five places in this library still carried the false claim that an Activity in Picture-in-
|
|
221
|
+
Picture never repaints its window. The accurate statement is that the app window's **UI
|
|
222
|
+
layer** stops producing frames while the Activity is paused, while a `SurfaceView` keeps
|
|
223
|
+
compositing; and what stops is **REACT**, in two ways —
|
|
224
|
+
`FabricUIManager.onHostPause()` removes the DISPATCH_UI frame callback, and
|
|
225
|
+
`JavaTimerManager.onHostPause()` freezes the timer registry. Corrected in
|
|
226
|
+
`MpvBridgeModule.kt`, `CHANGELOG.md`, `README.md`, `MpvPlayerModule.ts` and `config.ts`.
|
|
91
227
|
|
|
92
228
|
### Added
|
|
93
229
|
|
|
@@ -157,10 +293,10 @@
|
|
|
157
293
|
the SYSTEM transition the activity into PiP when the user leaves the app,
|
|
158
294
|
with the consumer unable to do anything first. That is the wrong order for a
|
|
159
295
|
consumer that draws its own chrome over the picture, because an Activity in
|
|
160
|
-
PiP is "paused, but rendering" (AOSP) - what stops is REACT:
|
|
161
|
-
|
|
162
|
-
is produced. So whatever its window held at the transition
|
|
163
|
-
window keeps showing. Measured on device on 2026-11-03, the
|
|
296
|
+
PiP is "paused, but rendering" (AOSP) - what stops is REACT: React Native
|
|
297
|
+
freezes in two ways while the Activity is paused, so a React commit cannot
|
|
298
|
+
land and no frame is produced. So whatever its window held at the transition
|
|
299
|
+
is what the PiP window keeps showing. Measured on device on 2026-11-03, the
|
|
164
300
|
consumer's full expanded chrome was painted into the PiP window, its
|
|
165
301
|
buttons were dead, and its clock was frozen three minutes behind the real
|
|
166
302
|
position.
|
package/README.md
CHANGED
|
@@ -369,7 +369,24 @@ override fun onUserLeaveHint() {
|
|
|
369
369
|
}
|
|
370
370
|
```
|
|
371
371
|
|
|
372
|
-
|
|
372
|
+
On Android 12+ (API 31+) there is a **better** hook, and it is the one that matters:
|
|
373
|
+
|
|
374
|
+
```kotlin
|
|
375
|
+
override fun onPictureInPictureRequested(): Boolean {
|
|
376
|
+
com.simba.player.mpv.MpvBridgeModule.notifyUserLeaveHint(this)
|
|
377
|
+
return true
|
|
378
|
+
}
|
|
379
|
+
```
|
|
380
|
+
|
|
381
|
+
Return `true`. AOSP's contract for that return value is "true if the activity received this
|
|
382
|
+
callback regardless of if it acts on it or not", and `false` sends the framework down the legacy
|
|
383
|
+
`onUserLeaveHint()` path instead.
|
|
384
|
+
|
|
385
|
+
**Keep both.** `onPictureInPictureRequested()` is API 31+; `onUserLeaveHint()` is the API 24-30
|
|
386
|
+
path. The same library call serves both, so there is one entry and one owner. Why the API 31+
|
|
387
|
+
hook matters is in [Why it is native](#why-it-is-native-and-why-your-activity-hands-over-the-activity).
|
|
388
|
+
|
|
389
|
+
The library then asks the OS for the window, hides your chrome, and brings your chrome back when
|
|
373
390
|
Picture-in-Picture ends. It returns whether the OS accepted the entry, so you can log it:
|
|
374
391
|
|
|
375
392
|
```kotlin
|
|
@@ -378,20 +395,53 @@ val entered = com.simba.player.mpv.MpvBridgeModule.notifyUserLeaveHint(this)
|
|
|
378
395
|
|
|
379
396
|
### Why it is native, and why your Activity hands over the Activity
|
|
380
397
|
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
398
|
+
Two reasons, and they are different.
|
|
399
|
+
|
|
400
|
+
**React Native has frozen by then.** `FabricUIManager.onHostPause()` removes the DISPATCH_UI
|
|
401
|
+
frame callback, so mount items are never applied to native views, and
|
|
402
|
+
`JavaTimerManager.onHostPause()` freezes the timer registry, so `requestAnimationFrame` never
|
|
403
|
+
fires. The JS runtime itself keeps running. Measured on emulator-5554 (API 37) on 2026-11-03: the
|
|
404
|
+
JS handler ran immediately, the effect that would have driven the entry ran **5.7 s late**, and
|
|
405
|
+
the `requestAnimationFrame` **never fired**. So the entry has to happen in native code.
|
|
406
|
+
|
|
407
|
+
**And on API 31+ the platform's own hooks are the wrong ones.** `Activity.onUserLeaveHint()`
|
|
408
|
+
used to be described as "the only hook Android gives you BEFORE the Activity is paused", and on
|
|
409
|
+
API 31+ that is **false**. With the platform's auto-enter switch armed, the platform
|
|
410
|
+
transitions your window itself, through the Shell transition, and your Activity is not
|
|
411
|
+
consulted: `onUserLeaveHint()` did **not fire at all** on a HOME press. Measured on
|
|
412
|
+
emulator-5554 (API 37) on 2026-11-04 — zero log lines, while the PiP window opened with the
|
|
413
|
+
app's full chrome in it.
|
|
414
|
+
|
|
415
|
+
`Activity.onPictureInPictureRequested()` is AOSP's own PiP entry hook, and it is called while
|
|
416
|
+
your Activity is still **RESUMED**. That matters twice over:
|
|
417
|
+
|
|
418
|
+
- `Activity.enterPictureInPictureMode()` throws `IllegalStateException` unless the Activity is
|
|
419
|
+
resumed, so this is the only moment an explicit entry is legal at all.
|
|
420
|
+
- your app is still drawing, so the chrome-less window is presented before the platform
|
|
421
|
+
transitions it.
|
|
422
|
+
|
|
423
|
+
That is why the library does **not** arm the platform's auto-enter switch: with it armed there
|
|
424
|
+
is no pre-transition hook to use.
|
|
425
|
+
|
|
426
|
+
### How your chrome is kept out of the PiP window
|
|
427
|
+
|
|
428
|
+
The PiP window **is** your Activity's own window, so whatever your chrome draws is what the PiP
|
|
429
|
+
window shows. The library hides your chrome root **before** it asks the OS for the window.
|
|
430
|
+
|
|
431
|
+
Two things have to be right for that to work:
|
|
384
432
|
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
the
|
|
389
|
-
|
|
390
|
-
|
|
433
|
+
1. **The hide happens in the entry, not after it.** Hiding from
|
|
434
|
+
`onPictureInPictureModeChanged(true)` — after the platform has already transitioned the
|
|
435
|
+
window — is too late. Measured on emulator-5554 (API 37) on 2026-11-04: the PiP window showed
|
|
436
|
+
the app's FULL expanded chrome, scaled down.
|
|
437
|
+
2. **The entry happens while your Activity is resumed.** On API 31+ that means
|
|
438
|
+
`onPictureInPictureRequested()`; see
|
|
439
|
+
[Why it is native](#why-it-is-native-and-why-your-activity-hands-over-the-activity).
|
|
391
440
|
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
441
|
+
`PictureInPictureParams.setSourceRectHint(...)` is **not** part of this. It is a TRANSITION
|
|
442
|
+
hint: it tells the platform which region of your window the PiP window should animate FROM. It
|
|
443
|
+
does **not** crop your window. (The 3.2.0 and 3.3.0 releases said otherwise; 3.3.1 retracts it,
|
|
444
|
+
with the device measurement that disproved it.)
|
|
395
445
|
|
|
396
446
|
### Telling the library which view is your chrome
|
|
397
447
|
|
|
@@ -416,21 +466,22 @@ about it:
|
|
|
416
466
|
```
|
|
417
467
|
|
|
418
468
|
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
|
|
469
|
+
your Activity's window decor view, and hides it natively when Picture-in-Picture starts. The
|
|
420
470
|
`nativeID` literal is yours - the library never hardcodes one of its own.
|
|
421
471
|
|
|
422
472
|
Omit `chromeNativeId` if your app draws no chrome of its own: the library then enters
|
|
423
473
|
Picture-in-Picture without hiding anything.
|
|
424
474
|
|
|
425
|
-
**If the `nativeID` is set and no view carries it, the
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
the library declines rather than reproduce it.
|
|
475
|
+
**If the `nativeID` is set and no view carries it, the chrome is already hidden** - your own
|
|
476
|
+
button path unmounts it in React before it asks for the window - so the library logs that and
|
|
477
|
+
carries on. It never refuses the entry over a missing view.
|
|
429
478
|
|
|
430
|
-
|
|
431
|
-
(`PictureInPictureParams.Builder.setAutoEnterEnabled`)
|
|
432
|
-
|
|
433
|
-
|
|
479
|
+
On **Android 12+** the library also arms Android's own auto-enter switch
|
|
480
|
+
(`PictureInPictureParams.Builder.setAutoEnterEnabled`), but **only while media is loaded**, and it
|
|
481
|
+
disarms it when playback stops: browsing the Home screen with nothing playing must not throw you
|
|
482
|
+
into a PiP window of a stopped session. While the switch is armed, the OS performs the entry
|
|
483
|
+
itself, and the library's explicit `enterPictureInPictureMode()` call is skipped (the platform
|
|
484
|
+
refuses it while auto-enter is enabled).
|
|
434
485
|
|
|
435
486
|
This works on **every** Android version - `onUserLeaveHint()` exists everywhere, and the platform's
|
|
436
487
|
own switch never existed below Android 12.
|
|
@@ -439,9 +490,12 @@ The two PiP flags combine: auto-enter needs `pip.enabled` and `pip.autoEnterOnLe
|
|
|
439
490
|
true.
|
|
440
491
|
|
|
441
492
|
|
|
442
|
-
The Picture-in-Picture action row has
|
|
443
|
-
|
|
444
|
-
|
|
493
|
+
The Picture-in-Picture action row has **one** button: **Play/Pause**, with a state-driven icon
|
|
494
|
+
(the pause icon while the video is playing, the play icon while it is paused). The platform
|
|
495
|
+
renders its own expand / close / settings affordances next to it. The button reaches the engine
|
|
496
|
+
directly - no JavaScript in the path - so it works even when the JS bundle is not running. The
|
|
497
|
+
`onPipPlayPause` event still exists in the API for compatibility, next to `onPipModeChanged`, but
|
|
498
|
+
it is not what pauses playback.
|
|
445
499
|
|
|
446
500
|
The media notification and lock screen are a separate surface. Its MediaSession advertises play,
|
|
447
501
|
pause, play/pause, stop, skip-to-next, skip-to-previous and seek-to, with title, artist and album
|
|
@@ -543,15 +597,24 @@ before launching, and check `commands.isSurfaceMounted()`.
|
|
|
543
597
|
**Picture-in-Picture does not start.** The Activity is missing
|
|
544
598
|
`android:supportsPictureInPicture="true"` or `android:resizeableActivity="true"`. If auto-enter
|
|
545
599
|
on leave does nothing, the Activity is not calling `MpvBridgeModule.notifyUserLeaveHint(this)`
|
|
546
|
-
from `
|
|
547
|
-
|
|
548
|
-
|
|
600
|
+
from `onPictureInPictureRequested()` (API 31+) or from `onUserLeaveHint()` (API 24-30) - see
|
|
601
|
+
[Picture-in-Picture](#picture-in-picture).
|
|
602
|
+
|
|
603
|
+
**The Picture-in-Picture window shows your app's chrome.** The chrome is hidden in the entry,
|
|
604
|
+
before the window is asked for — so the entry has to run while your Activity is resumed. On API
|
|
605
|
+
31+ that means `onPictureInPictureRequested()` must return `true` and call the library:
|
|
606
|
+
`onUserLeaveHint()` alone is **never called** there, because the platform's auto-enter switch
|
|
607
|
+
transitions the window itself (measured: zero log lines on a HOME press). The library logs the
|
|
608
|
+
hide (`companion.hideConsumerChrome`) and the entry (`companion.notifyUserLeaveHint`). A
|
|
609
|
+
`nativeID` in your config that no view carries is NOT a refusal: the chrome is already hidden, and
|
|
610
|
+
the library says so in the log.
|
|
549
611
|
|
|
550
612
|
**The Picture-in-Picture action row shows three buttons and none of them work.** That was the
|
|
551
613
|
explicit-broadcast bug, fixed in 3.1.0: the action's PendingIntent named the receiver's
|
|
552
614
|
component, and an explicit broadcast is resolved through the manifest, where the receiver was
|
|
553
615
|
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.
|
|
616
|
+
this package registers one, and a second registration delivers every action twice. Since 3.3.0
|
|
617
|
+
the row carries ONE button (play/pause) and the platform renders its own expand / close.
|
|
555
618
|
|
|
556
619
|
|
|
557
620
|
**Gradle fails with `libmpv.so not found at android/src/main/jniLibs/…`.** The postinstall
|