@simba-dev/react-native-media-player 1.8.3 → 1.8.4
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.
|
@@ -214,12 +214,43 @@ static std::string currentMpvPath() {
|
|
|
214
214
|
void eventLoop() {
|
|
215
215
|
TRACEI("Event loop started");
|
|
216
216
|
|
|
217
|
+
// ── Why this drains instead of blocking ────────────────────────────────
|
|
218
|
+
// mpv's own client.h states the rule this loop has to respect:
|
|
219
|
+
//
|
|
220
|
+
// "Property changes are coalesced: the change events are returned
|
|
221
|
+
// only once the event queue becomes empty (e.g. mpv_wait_event()
|
|
222
|
+
// would block or return MPV_EVENT_NONE), and then only one event
|
|
223
|
+
// per changed property is returned."
|
|
224
|
+
//
|
|
225
|
+
// So MPV_EVENT_PROPERTY_CHANGE is not delivered when the property
|
|
226
|
+
// changes — it is delivered when the queue happens to drain. A loop
|
|
227
|
+
// that blocks on `mpv_wait_event(-1)` and handles exactly one event
|
|
228
|
+
// before blocking again can starve every property event for as long
|
|
229
|
+
// as anything else keeps the queue non-empty. That is precisely the
|
|
230
|
+
// failure this used to have: MPV_EVENT_PROPERTY_CHANGE events were
|
|
231
|
+
// never observed on the handle the properties were observed on, so
|
|
232
|
+
// `onSeekable` / `onPositionChanged` / `onCacheState` never reached
|
|
233
|
+
// JS and the seek bar stayed permanently disabled.
|
|
234
|
+
//
|
|
235
|
+
// The drain below is the documented shape: poll with a zero timeout
|
|
236
|
+
// first, and only block when mpv reports MPV_EVENT_NONE — the exact
|
|
237
|
+
// state in which mpv is obliged to release the coalesced property
|
|
238
|
+
// changes. One queue-drained iteration costs one non-blocking call.
|
|
217
239
|
while (g_running.load()) {
|
|
218
|
-
mpv_event *event = mpv_wait_event(g_mpv,
|
|
240
|
+
mpv_event *event = mpv_wait_event(g_mpv, 0);
|
|
219
241
|
if (!event) {
|
|
220
242
|
LOGE("[PlaybackTrace][Native][eventLoop] mpv_wait_event returned null");
|
|
221
243
|
continue;
|
|
222
244
|
}
|
|
245
|
+
if (event->event_id == MPV_EVENT_NONE) {
|
|
246
|
+
// Queue is empty. Block until mpv has something for us; the
|
|
247
|
+
// wake-up will also flush any coalesced property changes.
|
|
248
|
+
event = mpv_wait_event(g_mpv, -1);
|
|
249
|
+
if (!event) {
|
|
250
|
+
LOGE("[PlaybackTrace][Native][eventLoop] mpv_wait_event returned null");
|
|
251
|
+
continue;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
223
254
|
TRACEI("[PlaybackTrace][Native][eventLoop] event_id=%d error=%d", event->event_id, event->error);
|
|
224
255
|
|
|
225
256
|
switch (event->event_id) {
|
|
@@ -326,6 +357,15 @@ void eventLoop() {
|
|
|
326
357
|
json = "null";
|
|
327
358
|
}
|
|
328
359
|
TRACEI("[PlaybackTrace][Native][property] name=%s format=%d value=%s", prop->name, prop->format, json.c_str());
|
|
360
|
+
// DEBUG (not TRACEI) on purpose. TRACEI is compiled to a
|
|
361
|
+
// no-op, which is why a broken property path was
|
|
362
|
+
// completely invisible in logcat for as long as it
|
|
363
|
+
// existed. This is the one line that makes
|
|
364
|
+
// "properties are observed but events never arrive"
|
|
365
|
+
// distinguishable from "the loop never saw them".
|
|
366
|
+
__android_log_print(ANDROID_LOG_DEBUG, "MpvProperty",
|
|
367
|
+
"[PlaybackTrace][Native][property] name=%s format=%d value=%s",
|
|
368
|
+
prop->name, prop->format, json.c_str());
|
|
329
369
|
callJavaPropertyChanged(prop->name, json.c_str());
|
|
330
370
|
break;
|
|
331
371
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@simba-dev/react-native-media-player",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.4",
|
|
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",
|
|
@@ -262,6 +262,30 @@ const POSITION_POLL_INTERVAL_MS = 1000;
|
|
|
262
262
|
* `demuxer-cache-state` is deliberately observed too: it is the only
|
|
263
263
|
* source for the buffered ranges that the seek bar paints behind the
|
|
264
264
|
* played fill.
|
|
265
|
+
*
|
|
266
|
+
* ---------------------------------------------------------------------------
|
|
267
|
+
* OPEN NATIVE DEFECT (1.8.4) — registration is fixed, delivery is not
|
|
268
|
+
* ---------------------------------------------------------------------------
|
|
269
|
+
* This list is necessary but NOT sufficient. Measured on emulator-5554
|
|
270
|
+
* (API 37) with the 1.8.3 code running and a file actively playing
|
|
271
|
+
* (`time-pos` advancing, `pause=false`):
|
|
272
|
+
*
|
|
273
|
+
* - `mpv_observe_property(...)` returns `result=0` for all twelve —
|
|
274
|
+
* registration genuinely succeeds.
|
|
275
|
+
* - `onPlaybackRestart` arrives 7,418 times; `onFileLoaded` arrives.
|
|
276
|
+
* So the native event loop IS pumping and IS dispatching to JS.
|
|
277
|
+
* - `onSeekable` / `onPositionChanged` / `onDurationChanged` /
|
|
278
|
+
* `onCacheState` / `onPlaybackStateChanged` arrive **0 times**.
|
|
279
|
+
*
|
|
280
|
+
* `MPV_EVENT_PROPERTY_CHANGE` is therefore never delivered to this
|
|
281
|
+
* handle even though the property is observed on it. The next release
|
|
282
|
+
* must fix the native property-event path (observe handle vs. pumped
|
|
283
|
+
* handle in `android/src/main/cpp/event.cpp` / `property.cpp`).
|
|
284
|
+
*
|
|
285
|
+
* Until that lands, the observable symptom is unchanged: the scrub bar
|
|
286
|
+
* still renders disabled ("Live stream — not seekable") because
|
|
287
|
+
* `seekable` never leaves `DEFAULT_PROGRESS`. Do not read a green test
|
|
288
|
+
* suite as evidence this works — the whole suite mocks the emitter.
|
|
265
289
|
*/
|
|
266
290
|
const OBSERVED_PROPERTIES: readonly string[] = [
|
|
267
291
|
'time-pos',
|