@simba-dev/react-native-media-player 2.0.1 → 2.1.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.
Files changed (34) hide show
  1. package/README.md +317 -560
  2. package/android/src/main/cpp/main.cpp +117 -17
  3. package/android/src/main/java/com/simba/player/PipManager.kt +13 -0
  4. package/android/src/main/java/com/simba/player/mpv/MpvBridgeModule.kt +177 -6
  5. package/android/src/main/java/com/simba/player/mpv/PipAutoEnterPolicy.kt +54 -0
  6. package/package.json +11 -2
  7. package/android/src/test/java/com/simba/player/PipActionReceiverTest.kt +0 -123
  8. package/android/src/test/java/com/simba/player/PipManagerTest.kt +0 -281
  9. package/android/src/test/java/com/simba/player/TestApplication.kt +0 -26
  10. package/android/src/test/java/com/simba/player/mpv/MpvBridgeModuleNullInstanceTest.kt +0 -117
  11. package/android/src/test/java/com/simba/player/mpv/MpvBridgeModuleTest.kt +0 -212
  12. package/android/src/test/java/com/simba/player/mpv/MpvRenderViewRegistryTest.kt +0 -120
  13. package/android/src/test/java/com/simba/player/mpv/MpvRenderViewTest.kt +0 -249
  14. package/scripts/override_react_methods.js +0 -184
  15. package/scripts/override_react_methods.py +0 -150
  16. package/src/bridge/__tests__/MpvPlayerModule.test.ts +0 -163
  17. package/src/bridge/__tests__/debugMode.test.ts +0 -138
  18. package/src/bridge/__tests__/errorContract.test.ts +0 -175
  19. package/src/bridge/__tests__/loadAndPlay.startPosition.test.tsx +0 -142
  20. package/src/components/__tests__/PlayerProvider.performance.test.tsx +0 -242
  21. package/src/components/__tests__/PlayerProvider.progressContext.test.tsx +0 -194
  22. package/src/components/__tests__/PlayerProvider.test.tsx +0 -558
  23. package/src/components/__tests__/PlayerRoot.test.tsx +0 -71
  24. package/src/components/__tests__/SimbaVideo.test.tsx +0 -164
  25. package/src/hooks/__tests__/resolveStreamType.test.ts +0 -159
  26. package/src/hooks/__tests__/useLaunchPlayback.test.tsx +0 -278
  27. package/src/hooks/__tests__/useResumeThumbnail.test.ts +0 -154
  28. package/src/stores/__tests__/playerQueueSelectionStore.test.ts +0 -73
  29. package/src/stores/__tests__/playerQueueStore.test.ts +0 -171
  30. package/src/types/__tests__/config.test.ts +0 -188
  31. package/src/types/__tests__/player.pipAnswer.test.tsx +0 -87
  32. package/src/types/__tests__/player.pipArity.test.tsx +0 -74
  33. package/src/types/__tests__/player.test.tsx +0 -1365
  34. package/src/types/__tests__/playerLoading.test.ts +0 -170
@@ -1,74 +0,0 @@
1
- /**
2
- * The PiP command must call the native bridge with TWO arguments.
3
- *
4
- * The native TurboModule method has arity 2, and TurboModule checks the
5
- * argument count on EVERY call, so a zero-argument call is rejected
6
- * before it ever reaches the native body:
7
- *
8
- * Exception in HostFunction: TurboModule method "enterPip"
9
- * called with 0 arguments (expected argument count: 2)
10
- *
11
- * That is what the PiP button did: it threw instead of entering PiP.
12
- * The native side had already been made nullable (v1.9.3) and the
13
- * codegen spec had already been given two parameters — but the CALL
14
- * SITE still passed none, and nothing tested the call site's arity.
15
- *
16
- * So this file asserts the arity, not the behaviour: a test that only
17
- * checked "enterPip was called" would pass with a zero-argument call
18
- * and the bug would survive.
19
- */
20
-
21
- import {NativeModules} from 'react-native';
22
- import {renderHook} from '@testing-library/react-native';
23
- import {usePlayer} from '../player';
24
-
25
- function enterPipMock(): jest.Mock {
26
- return (NativeModules.MpvPlayerModule as unknown as Record<string, jest.Mock>)
27
- .enterPip;
28
- }
29
-
30
- describe('commands.enterPip — the native call arity', () => {
31
- beforeEach(() => {
32
- for (const key of Object.keys(NativeModules.MpvPlayerModule)) {
33
- const fn = (NativeModules.MpvPlayerModule as unknown as Record<
34
- string,
35
- jest.Mock
36
- >)[key];
37
- if (typeof fn?.mockClear === 'function') {
38
- fn.mockClear();
39
- }
40
- }
41
- });
42
-
43
- it('calls the bridge with TWO arguments even when no values are given', async () => {
44
- const {result} = await renderHook(() => usePlayer());
45
- result.current.commands.enterPip();
46
-
47
- const enterPip = enterPipMock();
48
- expect(enterPip).toHaveBeenCalledTimes(1);
49
- // The arity is the whole point: TurboModule rejects anything else.
50
- expect(enterPip.mock.calls[0]).toHaveLength(2);
51
- // And the "not supplied" value is null, which the native accepts
52
- // (its own fallbacks are "Simba Player" and "0 %").
53
- expect(enterPip.mock.calls[0][0]).toBeNull();
54
- expect(enterPip.mock.calls[0][1]).toBeNull();
55
- });
56
-
57
- it('forwards the chapter title and the progress percentage', async () => {
58
- const {result} = await renderHook(() => usePlayer());
59
- result.current.commands.enterPip('Chapter 3', '45 %');
60
-
61
- const enterPip = enterPipMock();
62
- expect(enterPip.mock.calls[0]).toHaveLength(2);
63
- expect(enterPip).toHaveBeenCalledWith('Chapter 3', '45 %');
64
- });
65
-
66
- it('passes null for a value that was not supplied, not undefined', async () => {
67
- const {result} = await renderHook(() => usePlayer());
68
- result.current.commands.enterPip('Chapter 3', null);
69
-
70
- const enterPip = enterPipMock();
71
- expect(enterPip.mock.calls[0]).toHaveLength(2);
72
- expect(enterPip).toHaveBeenCalledWith('Chapter 3', null);
73
- });
74
- });