@simba-dev/react-native-media-player 1.13.8 → 1.14.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/README.md +26 -24
- package/android/src/main/java/com/simba/player/MediaPlaybackService.kt +20 -17
- package/android/src/main/java/com/simba/player/mpv/MpvBridgeModule.kt +18 -307
- package/android/src/test/java/com/simba/player/mpv/MpvBridgeModuleTest.kt +0 -20
- package/package.json +1 -1
- package/src/bridge/MpvPlayerModule.ts +36 -83
- package/src/bridge/NativeMpvPlayer.ts +15 -52
- package/src/bridge/loadAndPlay.ts +65 -0
- package/src/components/PlayerRoot.tsx +9 -13
- package/src/hooks/__tests__/useLaunchPlayback.test.tsx +44 -64
- package/src/hooks/useLaunchPlayback.ts +7 -11
- package/src/hooks/usePlayerActivity.ts +51 -60
- package/src/index.ts +5 -11
- package/src/types/__tests__/player.test.tsx +49 -17
- package/src/types/player.ts +28 -31
- package/android/src/main/java/com/simba/player/IMpvConfigProvider.kt +0 -36
- package/android/src/main/java/com/simba/player/IPipModeChangeEmitter.kt +0 -31
- package/android/src/main/java/com/simba/player/PlayerActivity.kt +0 -1626
- package/src/hooks/SimbaPlayerRoot.tsx +0 -128
- package/src/hooks/useIsPlayerActivity.ts +0 -61
- package/src/hooks/useLaunchParams.tsx +0 -126
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { useMemo } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
type LaunchParams,
|
|
5
|
-
} from '../bridge/MpvPlayerModule';
|
|
2
|
+
import { getMpvPlayerModule } from '../bridge/MpvPlayerModule';
|
|
3
|
+
import { loadAndPlay } from '../bridge/loadAndPlay';
|
|
6
4
|
|
|
7
5
|
/**
|
|
8
6
|
* Options accepted by `usePlayerActivity().openPlayer(opts)`. This is
|
|
@@ -17,16 +15,16 @@ export interface OpenPlayerOptions {
|
|
|
17
15
|
/** Display title for the notification / top bar. */
|
|
18
16
|
title: string;
|
|
19
17
|
/**
|
|
20
|
-
* `'video'`
|
|
21
|
-
* foreground media service and plays with no
|
|
18
|
+
* `'video'` loads into the mounted surface; `'audio'` starts the
|
|
19
|
+
* foreground media service and plays with no surface at all.
|
|
22
20
|
*
|
|
23
21
|
* That fork lives here rather than at the call sites on purpose.
|
|
24
22
|
* Three separate entry points reach this hook (`openPlayer`,
|
|
25
23
|
* `useOpenWithResume`, `useOpenPlaylist`) and a consumer has no way to
|
|
26
24
|
* tell which one a given screen uses. Deciding "does audio need a
|
|
27
|
-
*
|
|
28
|
-
* and the one forgotten would
|
|
29
|
-
*
|
|
25
|
+
* surface?" at each of those would mean three places to keep in sync,
|
|
26
|
+
* and the one forgotten would start a foreground service for a track
|
|
27
|
+
* with no notification artwork.
|
|
30
28
|
*/
|
|
31
29
|
type: 'video' | 'audio';
|
|
32
30
|
/** Resume position in milliseconds. 0 (or omitted) starts from the beginning. */
|
|
@@ -35,9 +33,10 @@ export interface OpenPlayerOptions {
|
|
|
35
33
|
* Optional artwork for the media notification's large icon — a local
|
|
36
34
|
* path, `file://`, or an `http(s)` URL.
|
|
37
35
|
*
|
|
38
|
-
* Audio only:
|
|
39
|
-
*
|
|
40
|
-
*
|
|
36
|
+
* Audio only: video renders into the consumer's own surface and the
|
|
37
|
+
* module never builds a notification for it, so it has nothing to be
|
|
38
|
+
* handed. Consumed by `startAudioPlayback`; ignored on the video path,
|
|
39
|
+
* which is why passing it unconditionally is safe.
|
|
41
40
|
*/
|
|
42
41
|
artworkPath?: string;
|
|
43
42
|
/**
|
|
@@ -50,27 +49,32 @@ export interface OpenPlayerOptions {
|
|
|
50
49
|
}
|
|
51
50
|
|
|
52
51
|
/**
|
|
53
|
-
*
|
|
54
|
-
* `
|
|
55
|
-
*
|
|
56
|
-
* previously launched `PlayerActivity` from screens like
|
|
57
|
-
* `NowPlaying`, `AllVideos`, `Bookmarks`, etc.
|
|
52
|
+
* Thin wrapper around the two launch paths, kept as a hook rather than a
|
|
53
|
+
* bare function so a consumer can `jest.mock` the whole module when it
|
|
54
|
+
* needs to stub launching from a test.
|
|
58
55
|
*
|
|
59
56
|
* Why a separate hook (not just `usePlayer().commands.openPlayer`):
|
|
60
|
-
* - `usePlayer()` requires a `<PlayerProvider>` ancestor for
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
* activity yet.
|
|
57
|
+
* - `usePlayer()` requires a `<PlayerProvider>` ancestor for live state;
|
|
58
|
+
* launch calls happen from screen components (lists, grids) that are
|
|
59
|
+
* not inside a player subtree.
|
|
64
60
|
* - Returning a smaller surface keeps the screen-side code
|
|
65
61
|
* self-documenting: "this screen launches the player" vs
|
|
66
62
|
* "this screen is inside the player".
|
|
67
|
-
* - Easier to mock in consumer-side tests (jest.mock the
|
|
68
|
-
* whole `usePlayerActivity` module).
|
|
69
63
|
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
64
|
+
* ## Video loads in-window (V21 F5)
|
|
65
|
+
*
|
|
66
|
+
* Video used to be handed to a dedicated `PlayerActivity` via
|
|
67
|
+
* `startActivity`. That is gone: the module now loads into the surface
|
|
68
|
+
* the consumer already has mounted, which is the whole reason the
|
|
69
|
+
* two-Activity architecture was removed — a `SurfaceView`'s Surface
|
|
70
|
+
* belongs to its window, so a second window made an in-app video
|
|
71
|
+
* mini-player impossible to build honestly.
|
|
72
|
+
*
|
|
73
|
+
* **The video branch refuses when no surface is mounted** and resolves
|
|
74
|
+
* `false`. Loading into nothing would start audio with no picture and
|
|
75
|
+
* report success, which is the "looks live and is not" failure this
|
|
76
|
+
* module exists to avoid. Presentation stays with the consumer's
|
|
77
|
+
* surface controller; this only decides *whether the load can happen*.
|
|
74
78
|
*
|
|
75
79
|
* @example
|
|
76
80
|
* ```tsx
|
|
@@ -90,30 +94,14 @@ export interface OpenPlayerOptions {
|
|
|
90
94
|
*/
|
|
91
95
|
export interface UsePlayerActivityResult {
|
|
92
96
|
/**
|
|
93
|
-
* Launch the
|
|
94
|
-
*
|
|
95
|
-
* `
|
|
96
|
-
*
|
|
97
|
-
* no-op mode
|
|
97
|
+
* Launch the given media. For `audio` this starts the foreground
|
|
98
|
+
* media service; for `video` it loads into the mounted surface.
|
|
99
|
+
* Resolves `true` when the launch was dispatched and `false`
|
|
100
|
+
* otherwise — audio could not start the service, or video was asked
|
|
101
|
+
* for while no surface was mounted, or the bridge is in no-op mode
|
|
102
|
+
* (jest / web preview, where there is no engine and no surface).
|
|
98
103
|
*/
|
|
99
104
|
openPlayer(opts: OpenPlayerOptions): Promise<boolean>;
|
|
100
|
-
/**
|
|
101
|
-
* One-shot accessor for the launch params the most recent
|
|
102
|
-
* `openPlayer` call handed to `PlayerActivity`. Resolves
|
|
103
|
-
* with `null` when called from MainActivity or after the
|
|
104
|
-
* first read has already consumed the value. The Kotlin
|
|
105
|
-
* side keeps a single-shot queue, so call this exactly
|
|
106
|
-
* once per `PlayerActivity.onCreate`.
|
|
107
|
-
*
|
|
108
|
-
* V22.0.0 / 1.5.8 (D-035 fix #6): the runtime returns a
|
|
109
|
-
* Promise (Kotlin `@ReactMethod` async). The previous sync
|
|
110
|
-
* return type was a type lie — the hook stored the
|
|
111
|
-
* Promise in `useState`, `if (launchParams != null)` was
|
|
112
|
-
* true (Promise is truthy), and downstream `bridge.loadFile`
|
|
113
|
-
* got `undefined` → `IllegalArgumentException` at the
|
|
114
|
-
* Kotlin bridge. Callers must `await` this.
|
|
115
|
-
*/
|
|
116
|
-
getLaunchParams(): Promise<LaunchParams | null>;
|
|
117
105
|
}
|
|
118
106
|
|
|
119
107
|
export function usePlayerActivity(): UsePlayerActivityResult {
|
|
@@ -123,7 +111,7 @@ export function usePlayerActivity(): UsePlayerActivityResult {
|
|
|
123
111
|
const bridge = getMpvPlayerModule();
|
|
124
112
|
const startPositionMs = opts.startPositionMs ?? 0;
|
|
125
113
|
|
|
126
|
-
// Audio never
|
|
114
|
+
// Audio never touches a surface. See `OpenPlayerOptions.type`.
|
|
127
115
|
if (opts.type === 'audio') {
|
|
128
116
|
return bridge.startAudioPlayback({
|
|
129
117
|
uri: opts.uri,
|
|
@@ -141,18 +129,21 @@ export function usePlayerActivity(): UsePlayerActivityResult {
|
|
|
141
129
|
});
|
|
142
130
|
}
|
|
143
131
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
132
|
+
// Video: refuse rather than load into nothing. See the class
|
|
133
|
+
// docblock — reporting success here would start playback the
|
|
134
|
+
// user cannot see and the caller cannot detect.
|
|
135
|
+
if (!bridge.isSurfaceMounted()) {
|
|
136
|
+
return Promise.resolve(false);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
loadAndPlay(bridge, {
|
|
140
|
+
uri: opts.uri,
|
|
141
|
+
title: opts.title,
|
|
148
142
|
startPositionMs,
|
|
149
|
-
);
|
|
150
|
-
|
|
151
|
-
getLaunchParams: () => {
|
|
152
|
-
const bridge = getMpvPlayerModule();
|
|
153
|
-
return bridge.getLaunchParams();
|
|
143
|
+
});
|
|
144
|
+
return Promise.resolve(true);
|
|
154
145
|
},
|
|
155
146
|
}),
|
|
156
147
|
[],
|
|
157
148
|
);
|
|
158
|
-
}
|
|
149
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -76,7 +76,6 @@ export {
|
|
|
76
76
|
} from './hooks/useOpenWithResume';
|
|
77
77
|
|
|
78
78
|
export {SimbaPlayer, type SimbaPlayerProps, type ResumePolicy} from './hooks/SimbaPlayer';
|
|
79
|
-
export {SimbaPlayerRoot, type SimbaPlayerRootProps} from './hooks/SimbaPlayerRoot';
|
|
80
79
|
export {useOpenFromUrl} from './hooks/useOpenFromUrl';
|
|
81
80
|
export {
|
|
82
81
|
useOpenPlaylist,
|
|
@@ -99,7 +98,6 @@ export {
|
|
|
99
98
|
useQueueSelectedIndices,
|
|
100
99
|
type PlayerQueueSelectionStore,
|
|
101
100
|
} from './hooks/useQueueSelection';
|
|
102
|
-
export {useLaunchParams} from './hooks/useLaunchParams';
|
|
103
101
|
// v1.10.0 — the "frame at the position you left off" thumbnail. The
|
|
104
102
|
// first genuinely PUBLIC frame API: `screenshot` / `captureThumbnail`
|
|
105
103
|
// live in the bridge but were never exported here, so a consumer had
|
|
@@ -112,16 +110,12 @@ export {
|
|
|
112
110
|
DEFAULT_FRAME_QUALITY,
|
|
113
111
|
type CaptureFrameOptions,
|
|
114
112
|
} from './hooks/useResumeThumbnail';
|
|
115
|
-
//
|
|
116
|
-
//
|
|
117
|
-
//
|
|
118
|
-
//
|
|
113
|
+
// V21 F5 — the load half of `<PlayerRoot>`, and the in-window launch
|
|
114
|
+
// primitive. Video no longer starts an Activity, so a consumer that
|
|
115
|
+
// wants to play media into its own already-mounted surface drives it
|
|
116
|
+
// from here: pass the payload, and `useLaunchPlayback` loads it exactly
|
|
117
|
+
// once. See its docstring for the once-per-payload contract.
|
|
119
118
|
export {useLaunchPlayback} from './hooks/useLaunchPlayback';
|
|
120
|
-
// V19 W6.0 — synchronous, idempotent "is this tree hosted by
|
|
121
|
-
// PlayerActivity?" predicate for consumers that render their own
|
|
122
|
-
// chrome over the native video surface. See the hook's docstring for
|
|
123
|
-
// why `useLaunchParams` is the wrong tool for that question.
|
|
124
|
-
export {useIsPlayerActivity} from './hooks/useIsPlayerActivity';
|
|
125
119
|
|
|
126
120
|
export {
|
|
127
121
|
getMpvPlayerModule,
|
|
@@ -194,7 +194,10 @@ describe('usePlayer (no provider)', () => {
|
|
|
194
194
|
expect(typeof c.setScreenBrightness).toBe('function');
|
|
195
195
|
expect(typeof c.requestNotificationPermission).toBe('function');
|
|
196
196
|
expect(typeof c.openPlayer).toBe('function');
|
|
197
|
-
|
|
197
|
+
// V21 F5: `getLaunchParams` is gone. It read a one-shot native queue
|
|
198
|
+
// that only the deleted Activity ever filled, so it would have
|
|
199
|
+
// resolved `null` forever.
|
|
200
|
+
expect((c as Record<string, unknown>).getLaunchParams).toBeUndefined();
|
|
198
201
|
expect(typeof c.getProperty).toBe('function');
|
|
199
202
|
expect(typeof c.setProperty).toBe('function');
|
|
200
203
|
expect(typeof c.observeProperty).toBe('function');
|
|
@@ -258,7 +261,7 @@ describe('usePlayer (no provider)', () => {
|
|
|
258
261
|
expect(NativeModules.MpvPlayerModule.seekBackward).toHaveBeenCalledWith(3);
|
|
259
262
|
});
|
|
260
263
|
|
|
261
|
-
it('commands.openPlayer
|
|
264
|
+
it('commands.openPlayer sends audio to the foreground service, not a window', async () => {
|
|
262
265
|
const { result } = await renderHook(() => usePlayer());
|
|
263
266
|
await result.current.commands.openPlayer({
|
|
264
267
|
uri: 'file:///song.mp3',
|
|
@@ -266,27 +269,56 @@ describe('usePlayer (no provider)', () => {
|
|
|
266
269
|
type: 'audio',
|
|
267
270
|
startPositionMs: 12345,
|
|
268
271
|
});
|
|
269
|
-
expect(NativeModules.MpvPlayerModule.
|
|
270
|
-
'file:///song.mp3',
|
|
271
|
-
'Song',
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
);
|
|
272
|
+
expect(NativeModules.MpvPlayerModule.startAudioPlayback).toHaveBeenCalledWith({
|
|
273
|
+
uri: 'file:///song.mp3',
|
|
274
|
+
title: 'Song',
|
|
275
|
+
startPositionMs: 12345,
|
|
276
|
+
autoPlay: true,
|
|
277
|
+
});
|
|
278
|
+
// Video never touches the service, and nothing starts an Activity.
|
|
279
|
+
expect(NativeModules.MpvPlayerModule.loadFile).not.toHaveBeenCalled();
|
|
275
280
|
});
|
|
276
281
|
|
|
277
|
-
|
|
282
|
+
// V21 F5: video used to be handed to a dedicated Activity via
|
|
283
|
+
// `startActivity`. It now loads into the surface the consumer already
|
|
284
|
+
// mounted. These two tests pin the halves of that that matter.
|
|
285
|
+
it('commands.openPlayer loads video into the mounted surface', async () => {
|
|
286
|
+
NativeModules.MpvPlayerModule.isSurfaceMounted.mockReturnValue(true);
|
|
278
287
|
const { result } = await renderHook(() => usePlayer());
|
|
279
|
-
await result.current.commands.openPlayer({
|
|
280
|
-
uri: 'file:///
|
|
281
|
-
title: '
|
|
288
|
+
const ok = await result.current.commands.openPlayer({
|
|
289
|
+
uri: 'file:///film.mp4',
|
|
290
|
+
title: 'Film',
|
|
282
291
|
type: 'video',
|
|
292
|
+
startPositionMs: 5000,
|
|
283
293
|
});
|
|
284
|
-
expect(
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
294
|
+
expect(ok).toBe(true);
|
|
295
|
+
// Ordering is the contract: force-media-title is read at load time,
|
|
296
|
+
// and seek must follow load or it applies to the previous file.
|
|
297
|
+
expect(NativeModules.MpvPlayerModule.setProperty).toHaveBeenCalledWith(
|
|
298
|
+
'force-media-title',
|
|
299
|
+
'Film',
|
|
300
|
+
);
|
|
301
|
+
expect(NativeModules.MpvPlayerModule.loadFile).toHaveBeenCalledWith(
|
|
302
|
+
'file:///film.mp4',
|
|
289
303
|
);
|
|
304
|
+
expect(NativeModules.MpvPlayerModule.seekAbsolute).toHaveBeenCalledWith(5);
|
|
305
|
+
expect(NativeModules.MpvPlayerModule.play).toHaveBeenCalled();
|
|
306
|
+
});
|
|
307
|
+
|
|
308
|
+
// "Must not" test: loading into a surface that does not exist starts
|
|
309
|
+
// audio the user cannot see and reports success. Faithful mutant =
|
|
310
|
+
// delete the `isSurfaceMounted()` guard.
|
|
311
|
+
it('commands.openPlayer REFUSES video when no surface is mounted', async () => {
|
|
312
|
+
NativeModules.MpvPlayerModule.isSurfaceMounted.mockReturnValue(false);
|
|
313
|
+
const { result } = await renderHook(() => usePlayer());
|
|
314
|
+
const ok = await result.current.commands.openPlayer({
|
|
315
|
+
uri: 'file:///film.mp4',
|
|
316
|
+
title: 'Film',
|
|
317
|
+
type: 'video',
|
|
318
|
+
});
|
|
319
|
+
expect(ok).toBe(false);
|
|
320
|
+
expect(NativeModules.MpvPlayerModule.loadFile).not.toHaveBeenCalled();
|
|
321
|
+
expect(NativeModules.MpvPlayerModule.play).not.toHaveBeenCalled();
|
|
290
322
|
});
|
|
291
323
|
|
|
292
324
|
// V22.0.0 / 1.6.0 additions — surface-widening for the V19 vertical-swipe
|
package/src/types/player.ts
CHANGED
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
MpvFileInfo,
|
|
11
11
|
applyForceMediaTitle,
|
|
12
12
|
} from '../bridge/MpvPlayerModule';
|
|
13
|
+
import { loadAndPlay } from '../bridge/loadAndPlay';
|
|
13
14
|
|
|
14
15
|
/**
|
|
15
16
|
* V13 Phase 51: expanded `PlayerState`. The V12 surface (4 fields)
|
|
@@ -247,12 +248,15 @@ export interface PlayerCommands {
|
|
|
247
248
|
/** Request the `POST_NOTIFICATIONS` permission on Android 13+. */
|
|
248
249
|
requestNotificationPermission(): void;
|
|
249
250
|
|
|
250
|
-
//
|
|
251
|
+
// Playback launch
|
|
251
252
|
/**
|
|
252
|
-
*
|
|
253
|
-
*
|
|
254
|
-
*
|
|
255
|
-
*
|
|
253
|
+
* Launch the given media. `audio` starts the foreground media service;
|
|
254
|
+
* `video` loads into the consumer's already-mounted surface and
|
|
255
|
+
* resolves `false` when no surface is mounted, rather than starting
|
|
256
|
+
* playback nobody can see.
|
|
257
|
+
*
|
|
258
|
+
* V21 F5: video no longer hands off to a dedicated `PlayerActivity`.
|
|
259
|
+
* The signature is unchanged — the video lane's destination is.
|
|
256
260
|
*/
|
|
257
261
|
openPlayer(opts: {
|
|
258
262
|
uri: string;
|
|
@@ -260,22 +264,6 @@ export interface PlayerCommands {
|
|
|
260
264
|
type: 'video' | 'audio';
|
|
261
265
|
startPositionMs?: number;
|
|
262
266
|
}): Promise<boolean>;
|
|
263
|
-
/**
|
|
264
|
-
* One-shot accessor for the launch params the most recent
|
|
265
|
-
* `openPlayer` handed to `PlayerActivity`.
|
|
266
|
-
*
|
|
267
|
-
* V22.0.0 / 1.5.8 (D-035 fix #6): now correctly typed as a
|
|
268
|
-
* Promise — the Kotlin bridge method is `@ReactMethod` async.
|
|
269
|
-
* The previous sync signature was a type lie that caused
|
|
270
|
-
* `setParams(<Promise>)` in the consumer and a downstream
|
|
271
|
-
* `loadFile(undefined)` RedBox. Callers should `await` this.
|
|
272
|
-
*/
|
|
273
|
-
getLaunchParams(): Promise<{
|
|
274
|
-
uri: string;
|
|
275
|
-
title: string;
|
|
276
|
-
type: 'video' | 'audio';
|
|
277
|
-
startPositionMs: number;
|
|
278
|
-
} | null>;
|
|
279
267
|
|
|
280
268
|
// Generic property access (used by audioSettingsService, metadataService)
|
|
281
269
|
/** Get the value of an mpv property as a string. */
|
|
@@ -681,16 +669,25 @@ function buildCommands(): PlayerCommands {
|
|
|
681
669
|
|
|
682
670
|
openPlayer: async (opts) => {
|
|
683
671
|
dlog('commands.openPlayer(', opts, ')');
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
672
|
+
const bridge = getMpvPlayerModule();
|
|
673
|
+
const startPositionMs = opts.startPositionMs ?? 0;
|
|
674
|
+
|
|
675
|
+
if (opts.type === 'audio') {
|
|
676
|
+
return bridge.startAudioPlayback({
|
|
677
|
+
uri: opts.uri,
|
|
678
|
+
title: opts.title,
|
|
679
|
+
startPositionMs,
|
|
680
|
+
autoPlay: true,
|
|
681
|
+
});
|
|
682
|
+
}
|
|
683
|
+
|
|
684
|
+
// Video: refuse when there is no surface rather than loading into
|
|
685
|
+
// nothing. See `usePlayerActivity.openPlayer` for why.
|
|
686
|
+
if (!bridge.isSurfaceMounted()) {
|
|
687
|
+
return false;
|
|
688
|
+
}
|
|
689
|
+
loadAndPlay(bridge, {uri: opts.uri, title: opts.title, startPositionMs});
|
|
690
|
+
return true;
|
|
694
691
|
},
|
|
695
692
|
|
|
696
693
|
getProperty: (name: string) => {
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
package com.simba.player
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Module-side contract that lets `PlayerActivity` (in the module) read
|
|
5
|
-
* the latest `PlayerConfig` (set by `<PlayerProvider config={...}>` in
|
|
6
|
-
* JS) without crossing the Gradle module boundary into the consumer
|
|
7
|
-
* app's bridge code.
|
|
8
|
-
*
|
|
9
|
-
* Pattern mirrors [IPipModeChangeEmitter] (Phase 10): the consumer app's
|
|
10
|
-
* `MpvBridgeModule` implements this contract; module code looks it up
|
|
11
|
-
* via `reactContext.getNativeModule("MpvPlayerModule") as?
|
|
12
|
-
* IMpvConfigProvider` and casts. The cast is safe because we control
|
|
13
|
-
* both sides of the boundary.
|
|
14
|
-
*
|
|
15
|
-
* Phase 21 deliverable: `PlayerActivity.onCreate` looks up the bridge
|
|
16
|
-
* module and calls [getCurrentConfig] so the activity logs which keys
|
|
17
|
-
* are active (matches the spec's "verify config is picked up" step).
|
|
18
|
-
* Future phases (22-25) extend the lookup to read theme + pip + audio
|
|
19
|
-
* settings and apply them.
|
|
20
|
-
*
|
|
21
|
-
* Why this survives V20 Phase A while its sibling did not: this contract
|
|
22
|
-
* carries data pushed *by React*, so it genuinely needs the React
|
|
23
|
-
* context to reach. The native-pointer contract it used to mirror did
|
|
24
|
-
* not — it carried a process-global, so V20 replaced it with
|
|
25
|
-
* `PlaybackHost`, and it was deleted rather than left as fiction.
|
|
26
|
-
*/
|
|
27
|
-
interface IMpvConfigProvider {
|
|
28
|
-
/**
|
|
29
|
-
* @return the most recent PlayerConfig pushed via
|
|
30
|
-
* `MpvPlayerModule.setConfig(...)`, as a Kotlin Map mirroring
|
|
31
|
-
* the JSON structure. `null` when no config has been set
|
|
32
|
-
* yet (the consumer app never wrapped its root in
|
|
33
|
-
* `<PlayerProvider>`).
|
|
34
|
-
*/
|
|
35
|
-
fun getCurrentConfig(): Map<String, Any?>?
|
|
36
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
package com.simba.player
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Module-side contract that lets `PlayerActivity` (in the module)
|
|
5
|
-
* emit PiP mode-change events to JS without holding a direct reference
|
|
6
|
-
* to `MpvBridgeModule`.
|
|
7
|
-
*
|
|
8
|
-
* The consumer app's bridge module implements this contract; module code
|
|
9
|
-
* looks it up via `reactContext.getNativeModule("MpvPlayerModule") as?
|
|
10
|
-
* IPipModeChangeEmitter` and casts. The cast is safe because we control
|
|
11
|
-
* both sides.
|
|
12
|
-
*
|
|
13
|
-
* Phase 10 deliverable: `PlayerActivity.onPictureInPictureModeChanged`
|
|
14
|
-
* looks up the bridge module and calls [emitPictureInPictureModeChanged]
|
|
15
|
-
* so JS receives the same `onPipModeChanged` event it received in V11
|
|
16
|
-
* (where `MainActivity.onPictureInPictureModeChanged` called
|
|
17
|
-
* `MpvBridgeModule.onPictureInPictureModeChanged(isInPip)` directly).
|
|
18
|
-
*
|
|
19
|
-
* Unlike the native-pointer contract this once mirrored, this one
|
|
20
|
-
* genuinely needs the React context - it exists to deliver an event
|
|
21
|
-
* *to JS*. That is why it survives V20 Phase A while that one was
|
|
22
|
-
* deleted and replaced by `PlaybackHost`.
|
|
23
|
-
*/
|
|
24
|
-
interface IPipModeChangeEmitter {
|
|
25
|
-
/**
|
|
26
|
-
* Tell the JS layer that the activity entered / exited PiP mode.
|
|
27
|
-
* Emits an `onPipModeChanged` event with `{ isInPip: Boolean }` to
|
|
28
|
-
* the JS `DeviceEventEmitter`.
|
|
29
|
-
*/
|
|
30
|
-
fun emitPictureInPictureModeChanged(isInPictureInPictureMode: Boolean)
|
|
31
|
-
}
|