@simba-dev/react-native-media-player 1.13.0 → 1.13.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.
@@ -2064,27 +2064,43 @@ class MpvBridgeModule(reactContext: ReactApplicationContext) :
2064
2064
  promise.resolve(true)
2065
2065
  }
2066
2066
 
2067
+ /**
2068
+ * The one teardown, for both lanes.
2069
+ *
2070
+ * Renamed from `stopAudioPlayback` because the body never was
2071
+ * audio-specific: it stops the process-global engine and sends the
2072
+ * service `ACTION_STOP`, neither of which knows or cares which lane
2073
+ * loaded the media. The old name became a lie the moment video
2074
+ * needed it too — and video does, because `exitPipAndFinish()` only
2075
+ * finishes the Activity. Closing the window left the engine running
2076
+ * with the notification still posted, so "back" looked like it closed
2077
+ * the player while the audio carried on with no window to stop it.
2078
+ *
2079
+ * Idempotent: safe with nothing loaded, and safe when the service is
2080
+ * already gone (the engine is still stopped in that case, because
2081
+ * leaving media running with no way to stop it is the worse failure).
2082
+ */
2067
2083
  @ReactMethod
2068
2084
  @Override
2069
- override fun stopAudioPlayback() {
2085
+ override fun stopPlayback() {
2070
2086
  val context = reactApplicationContext
2071
2087
  val serviceUp = com.simba.player.MediaPlaybackService.isRunning()
2072
2088
  // Stop the engine unconditionally. If the service is already
2073
2089
  // gone, the session's own stop callback is not around to do it,
2074
- // and leaving audio running with no way to stop it is the worse
2090
+ // and leaving media running with no way to stop it is the worse
2075
2091
  // failure of the two.
2076
2092
  if (nativePtr != 0L) {
2077
2093
  try {
2078
2094
  MPVLib.nativeStop(nativePtr)
2079
2095
  } catch (e: Throwable) {
2080
- Log.w(TAG, "[PlaybackTrace][Bridge][stopAudioPlayback] nativeStop threw ${e.message}")
2096
+ Log.w(TAG, "[PlaybackTrace][Bridge][stopPlayback] nativeStop threw ${e.message}")
2081
2097
  }
2082
2098
  } else {
2083
- Log.w(TAG, "[PlaybackTrace][Bridge][stopAudioPlayback] no engine handle; nothing to stop")
2099
+ Log.w(TAG, "[PlaybackTrace][Bridge][stopPlayback] no engine handle; nothing to stop")
2084
2100
  }
2085
2101
 
2086
2102
  if (!serviceUp) {
2087
- Log.i(TAG, "[PlaybackTrace][Bridge][stopAudioPlayback] service not running; engine stopped, nothing to tear down")
2103
+ Log.i(TAG, "[PlaybackTrace][Bridge][stopPlayback] service not running; engine stopped, nothing to tear down")
2088
2104
  return
2089
2105
  }
2090
2106
  try {
@@ -2096,7 +2112,7 @@ class MpvBridgeModule(reactContext: ReactApplicationContext) :
2096
2112
  },
2097
2113
  )
2098
2114
  } catch (e: Throwable) {
2099
- Log.e(TAG, "[PlaybackTrace][Bridge][stopAudioPlayback] could not deliver ACTION_STOP", e)
2115
+ Log.e(TAG, "[PlaybackTrace][Bridge][stopPlayback] could not deliver ACTION_STOP", e)
2100
2116
  }
2101
2117
  }
2102
2118
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@simba-dev/react-native-media-player",
3
- "version": "1.13.0",
3
+ "version": "1.13.1",
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",
@@ -191,7 +191,7 @@ export interface CaptureFrameOptions {
191
191
  * - Filters + playlist
192
192
  * - State queries
193
193
  * - Activity launch (openPlayer/getLaunchParams)
194
- * - Audio without an Activity (startAudioPlayback/stopAudioPlayback)
194
+ * - Audio without an Activity (startAudioPlayback/stopPlayback)
195
195
  * - Configuration (setConfig)
196
196
  * - PiP + screen
197
197
  * - Orientation + immersive
@@ -413,8 +413,8 @@ export interface MpvPlayerModuleBridge {
413
413
  startPositionMs?: number;
414
414
  autoPlay?: boolean;
415
415
  }): Promise<boolean>;
416
- /** Stop playback and tear the foreground service down. */
417
- stopAudioPlayback(): void;
416
+ /** Stop playback and tear the foreground service down. Both lanes. */
417
+ stopPlayback(): void;
418
418
  /** Whether the foreground service currently holds a live session. */
419
419
  isAudioPlaybackServiceRunning(): boolean;
420
420
  /**
@@ -686,7 +686,7 @@ const NOOP_BRIDGE: MpvPlayerModuleBridge = {
686
686
  void _options;
687
687
  return Promise.resolve(false);
688
688
  },
689
- stopAudioPlayback: () => {},
689
+ stopPlayback: () => {},
690
690
  isAudioPlaybackServiceRunning: () => false,
691
691
  // V22.0.0 / 1.5.8 (D-035 fix #6): now matches the real
692
692
  // Promise<LaunchParams | null> runtime return type.
@@ -231,14 +231,22 @@ export interface Spec extends TurboModule {
231
231
  }): Promise<boolean>;
232
232
 
233
233
  /**
234
- * Stop playback and tear the foreground service down. This is the mini
235
- * player's close (X) verb — distinct from *minimize*, which is a React
236
- * state change and never reaches the native layer.
234
+ * Stop playback and tear the foreground service down.
235
+ *
236
+ * This is *the* teardown, for both lanes. It is what "close" means:
237
+ * the engine stops and the foreground service is released, so the
238
+ * notification goes away and the media keys stop driving a session.
239
+ * It is NOT what "minimize" means — minimize is a React state change
240
+ * and never reaches the native layer.
241
+ *
242
+ * Video needs this too. `exitPipAndFinish()` only finishes the
243
+ * Activity; the engine is process-global, so finishing the window
244
+ * left the media running with no window left to stop it.
237
245
  *
238
246
  * Synchronous and idempotent: the service's own `ACTION_STOP` handler
239
247
  * already tolerates being called when nothing is loaded.
240
248
  */
241
- stopAudioPlayback(): void;
249
+ stopPlayback(): void;
242
250
 
243
251
  /**
244
252
  * Whether the foreground service currently holds a live session.
@@ -173,6 +173,16 @@ describe('usePlayer (no provider)', () => {
173
173
  expect(typeof c.playlistRemove).toBe('function');
174
174
  expect(typeof c.shuffle).toBe('function');
175
175
  expect(typeof c.clear).toBe('function');
176
+ // `stopPlayback` is the FULL teardown (engine + foreground service).
177
+ // It must exist alongside `stop`, which only halts the engine and
178
+ // leaves the session and notification alive. Video's back button
179
+ // needs the full one: `exitPipAndFinish()` finishes the Activity, and
180
+ // the process-global engine would otherwise keep playing behind a
181
+ // closed window.
182
+ expect(typeof c.stopPlayback).toBe('function');
183
+ // The old lane-specific name must NOT survive — a consumer reaching
184
+ // for it would silently get undefined and skip the teardown.
185
+ expect((c as unknown as Record<string, unknown>).stopAudioPlayback).toBeUndefined();
176
186
  expect(typeof c.cycleTrack).toBe('function');
177
187
  expect(typeof c.setTrack).toBe('function');
178
188
  expect(typeof c.enterPip).toBe('function');
@@ -162,6 +162,11 @@ export interface PlayerCommands {
162
162
  togglePlayPause(): void;
163
163
  /** Stop playback entirely. */
164
164
  stop(): void;
165
+ /**
166
+ * Stop playback AND tear the foreground service down (notification
167
+ * dismissed, media session released). This is what "close" means.
168
+ */
169
+ stopPlayback(): void;
165
170
  /** Relative seek in milliseconds. Negative seeks backward. */
166
171
  seekBy(deltaMs: number): void;
167
172
  /** Seek to the chapter at `index` (via mpv `setProperty('chapter', index)`). */
@@ -511,6 +516,16 @@ function buildCommands(): PlayerCommands {
511
516
  dlog('commands.stop()');
512
517
  getMpvPlayerModule().stop();
513
518
  },
519
+ /**
520
+ * The full teardown: engine + foreground service. Distinct from
521
+ * `stop()`, which only halts the engine and leaves the session and
522
+ * notification alive — correct for "pause the media, keep the
523
+ * transport available", wrong for "close the player".
524
+ */
525
+ stopPlayback: () => {
526
+ dlog('commands.stopPlayback()');
527
+ getMpvPlayerModule().stopPlayback();
528
+ },
514
529
  seekBy: (deltaMs: number) => {
515
530
  dlog('commands.seekBy(', deltaMs, ')');
516
531
  const deltaSec = Math.abs(deltaMs / 1000);