@simba-dev/react-native-media-player 2.0.0 → 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.
- package/README.md +317 -560
- package/android/src/main/cpp/main.cpp +117 -17
- package/android/src/main/java/com/simba/player/PipManager.kt +13 -0
- package/android/src/main/java/com/simba/player/mpv/MpvBridgeModule.kt +187 -8
- package/android/src/main/java/com/simba/player/mpv/MpvRenderViewManager.kt +11 -1
- package/android/src/main/java/com/simba/player/mpv/MpvRenderViewRegistry.kt +132 -0
- package/android/src/main/java/com/simba/player/mpv/PipAutoEnterPolicy.kt +54 -0
- package/android/src/main/java/com/simba/player/mpv/PlayerSurface.kt +41 -1
- package/package.json +11 -2
- package/src/bridge/MpvPlayerModule.ts +7 -1
- package/src/bridge/NativeMpvPlayer.ts +3 -3
- package/src/types/player.ts +7 -1
- package/android/src/test/java/com/simba/player/PipActionReceiverTest.kt +0 -123
- package/android/src/test/java/com/simba/player/PipManagerTest.kt +0 -281
- package/android/src/test/java/com/simba/player/TestApplication.kt +0 -26
- package/android/src/test/java/com/simba/player/mpv/MpvBridgeModuleNullInstanceTest.kt +0 -117
- package/android/src/test/java/com/simba/player/mpv/MpvBridgeModuleTest.kt +0 -212
- package/android/src/test/java/com/simba/player/mpv/MpvRenderViewTest.kt +0 -249
- package/scripts/override_react_methods.js +0 -184
- package/scripts/override_react_methods.py +0 -150
- package/src/bridge/__tests__/MpvPlayerModule.test.ts +0 -110
- package/src/bridge/__tests__/debugMode.test.ts +0 -138
- package/src/bridge/__tests__/errorContract.test.ts +0 -175
- package/src/bridge/__tests__/loadAndPlay.startPosition.test.tsx +0 -142
- package/src/components/__tests__/PlayerProvider.performance.test.tsx +0 -242
- package/src/components/__tests__/PlayerProvider.progressContext.test.tsx +0 -194
- package/src/components/__tests__/PlayerProvider.test.tsx +0 -558
- package/src/components/__tests__/PlayerRoot.test.tsx +0 -71
- package/src/components/__tests__/SimbaVideo.test.tsx +0 -164
- package/src/hooks/__tests__/resolveStreamType.test.ts +0 -159
- package/src/hooks/__tests__/useLaunchPlayback.test.tsx +0 -278
- package/src/hooks/__tests__/useResumeThumbnail.test.ts +0 -154
- package/src/stores/__tests__/playerQueueSelectionStore.test.ts +0 -73
- package/src/stores/__tests__/playerQueueStore.test.ts +0 -171
- package/src/types/__tests__/config.test.ts +0 -188
- package/src/types/__tests__/player.pipAnswer.test.tsx +0 -87
- package/src/types/__tests__/player.pipArity.test.tsx +0 -74
- package/src/types/__tests__/player.test.tsx +0 -1365
- package/src/types/__tests__/playerLoading.test.ts +0 -170
|
@@ -1,170 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* lib v1.17.0 — the "the file is OPENING" contract, and the error
|
|
3
|
-
* payload's numeric code.
|
|
4
|
-
*
|
|
5
|
-
* ## Why these tests exist
|
|
6
|
-
*
|
|
7
|
-
* Both claims were false on a device, and neither was visible in the
|
|
8
|
-
* test suite:
|
|
9
|
-
*
|
|
10
|
-
* - A load over a throttled link took 9 seconds and showed NO loading
|
|
11
|
-
* indicator. mpv's core state is "playing" from the moment
|
|
12
|
-
* `loadfile` is called until the file has been parsed, and the
|
|
13
|
-
* playlist is not populated until the file arrives — so "playing" and
|
|
14
|
-
* "idle" were both wrong, and no consumer could tell "opening" from
|
|
15
|
-
* either. `isLoading` is the fact, and the lib owns it because the
|
|
16
|
-
* lib is the only layer that knows a load was requested.
|
|
17
|
-
*
|
|
18
|
-
* - Every failure arrived with `code: NaN`. The native payload carried
|
|
19
|
-
* a STRING `code` ("E_RENDERER_GONE") where the contract declares
|
|
20
|
-
* `code: number`, so `Number("E_RENDERER_GONE")` was NaN — and the
|
|
21
|
-
* device log showed `numeric=0` for a real failure. The payload
|
|
22
|
-
* also arrived TWICE, the second emission overwriting the first.
|
|
23
|
-
*
|
|
24
|
-
* A test that cannot fail is not a test, so each claim below is pinned
|
|
25
|
-
* by an assertion that a regression would break.
|
|
26
|
-
*/
|
|
27
|
-
|
|
28
|
-
import {applyPlayerEvent, DEFAULT_PROGRESS, DEFAULT_STATE} from '../player';
|
|
29
|
-
|
|
30
|
-
describe('v1.17.0 — isLoading: the file is OPENING', () => {
|
|
31
|
-
it('is false in the default state (no load has been requested)', () => {
|
|
32
|
-
expect(DEFAULT_STATE.isLoading).toBe(false);
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
it('is true the moment a load is requested', () => {
|
|
36
|
-
const {state} = applyPlayerEvent(DEFAULT_STATE, DEFAULT_PROGRESS, 'onLoadRequested', {
|
|
37
|
-
uri: 'https://example.test/movie.mp4',
|
|
38
|
-
});
|
|
39
|
-
expect(state.isLoading).toBe(true);
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
it('stays true for the whole opening window', () => {
|
|
43
|
-
// Anything that happens while the file is opening must not clear
|
|
44
|
-
// it — a position change or a duration change during the load is
|
|
45
|
-
// not "the file arrived".
|
|
46
|
-
const requested = applyPlayerEvent(DEFAULT_STATE, DEFAULT_PROGRESS, 'onLoadRequested', {
|
|
47
|
-
uri: 'https://example.test/movie.mp4',
|
|
48
|
-
});
|
|
49
|
-
const positioned = applyPlayerEvent(requested.state, requested.progress, 'onPositionChanged', {
|
|
50
|
-
position: 0,
|
|
51
|
-
});
|
|
52
|
-
expect(positioned.state.isLoading).toBe(true);
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
it('is false once the file arrives', () => {
|
|
56
|
-
const requested = applyPlayerEvent(DEFAULT_STATE, DEFAULT_PROGRESS, 'onLoadRequested', {
|
|
57
|
-
uri: 'https://example.test/movie.mp4',
|
|
58
|
-
});
|
|
59
|
-
const loaded = applyPlayerEvent(requested.state, requested.progress, 'onFileLoaded', {
|
|
60
|
-
file: {title: 'A Movie', duration: 120},
|
|
61
|
-
});
|
|
62
|
-
expect(loaded.state.isLoading).toBe(false);
|
|
63
|
-
expect(loaded.state.isPlaying).toBe(true);
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
it('is false when the file ends — ended, or failed', () => {
|
|
67
|
-
// A load that FAILS never reaches onFileLoaded, so without this the
|
|
68
|
-
// lib would be stuck reporting "opening" for the rest of the
|
|
69
|
-
// session.
|
|
70
|
-
const loading = {...DEFAULT_STATE, isLoading: true};
|
|
71
|
-
const ended = applyPlayerEvent(loading, DEFAULT_PROGRESS, 'onEndFile', {reason: 3, error: 0});
|
|
72
|
-
expect(ended.state.isLoading).toBe(false);
|
|
73
|
-
});
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
describe('v1.17.0 — the onError payload carries a NUMERIC code', () => {
|
|
77
|
-
it('keeps a numeric code and the readable name', () => {
|
|
78
|
-
const {state} = applyPlayerEvent(DEFAULT_STATE, DEFAULT_PROGRESS, 'onError', {
|
|
79
|
-
code: 3001,
|
|
80
|
-
codeName: 'E_LOAD_FAILED',
|
|
81
|
-
recoverable: false,
|
|
82
|
-
message: 'failed to load',
|
|
83
|
-
});
|
|
84
|
-
expect(state.error).toEqual({
|
|
85
|
-
code: 3001,
|
|
86
|
-
codeName: 'E_LOAD_FAILED',
|
|
87
|
-
recoverable: false,
|
|
88
|
-
message: 'failed to load',
|
|
89
|
-
});
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
it('never produces NaN when the payload carries a string code', () => {
|
|
93
|
-
// This is the exact shape the native bridge used to emit, and
|
|
94
|
-
// `Number("E_RENDERER_GONE")` is NaN. The claim is that a failure
|
|
95
|
-
// must never reach the app with a NaN code.
|
|
96
|
-
const {state} = applyPlayerEvent(DEFAULT_STATE, DEFAULT_PROGRESS, 'onError', {
|
|
97
|
-
code: 'E_RENDERER_GONE',
|
|
98
|
-
codeName: 'E_RENDERER_GONE',
|
|
99
|
-
recoverable: false,
|
|
100
|
-
message: 'renderer gone',
|
|
101
|
-
});
|
|
102
|
-
expect(state.error).not.toBeNull();
|
|
103
|
-
expect(Number.isNaN(state.error?.code)).toBe(false);
|
|
104
|
-
expect(state.error?.code).toBe(0);
|
|
105
|
-
// The readable name survives, so the classifier still has something.
|
|
106
|
-
expect(state.error?.codeName).toBe('E_RENDERER_GONE');
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
it('keeps the recoverable flag — it means "playback continued"', () => {
|
|
110
|
-
// mpv's END_FILE path reports recoverable=false (the file failed);
|
|
111
|
-
// a fatal-level mpv LOG line reports true (playback continued). A
|
|
112
|
-
// consumer that shows a terminal error card must be able to tell
|
|
113
|
-
// them apart.
|
|
114
|
-
const terminal = applyPlayerEvent(DEFAULT_STATE, DEFAULT_PROGRESS, 'onError', {
|
|
115
|
-
code: 3001,
|
|
116
|
-
codeName: 'E_LOAD_FAILED',
|
|
117
|
-
recoverable: false,
|
|
118
|
-
message: 'failed',
|
|
119
|
-
});
|
|
120
|
-
expect(terminal.state.error?.recoverable).toBe(false);
|
|
121
|
-
|
|
122
|
-
const degraded = applyPlayerEvent(DEFAULT_STATE, DEFAULT_PROGRESS, 'onError', {
|
|
123
|
-
code: 3011,
|
|
124
|
-
codeName: 'E_GENERIC',
|
|
125
|
-
recoverable: true,
|
|
126
|
-
message: 'AudioTrack Init failed',
|
|
127
|
-
});
|
|
128
|
-
expect(degraded.state.error?.recoverable).toBe(true);
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
it('does not let a non-terminal failure mask a terminal one', () => {
|
|
132
|
-
// mpv can report a fatal-level LOG line AFTER the file has already
|
|
133
|
-
// failed. The last error to arrive is not necessarily the one that
|
|
134
|
-
// ended playback, so the terminal failure has to survive.
|
|
135
|
-
const terminal = applyPlayerEvent(DEFAULT_STATE, DEFAULT_PROGRESS, 'onError', {
|
|
136
|
-
code: 3001,
|
|
137
|
-
codeName: 'E_LOAD_FAILED',
|
|
138
|
-
recoverable: false,
|
|
139
|
-
message: 'failed to load',
|
|
140
|
-
});
|
|
141
|
-
const after = applyPlayerEvent(terminal.state, terminal.progress, 'onError', {
|
|
142
|
-
code: 3011,
|
|
143
|
-
codeName: 'E_GENERIC',
|
|
144
|
-
recoverable: true,
|
|
145
|
-
message: 'AudioTrack Init failed',
|
|
146
|
-
});
|
|
147
|
-
expect(after.state.error?.code).toBe(3001);
|
|
148
|
-
expect(after.state.error?.codeName).toBe('E_LOAD_FAILED');
|
|
149
|
-
expect(after.state.error?.recoverable).toBe(false);
|
|
150
|
-
});
|
|
151
|
-
|
|
152
|
-
it('lets a NEWER terminal failure replace the previous one', () => {
|
|
153
|
-
// A retry that fails again must report the new failure, not the
|
|
154
|
-
// previous one — otherwise the card keeps showing a stale reason.
|
|
155
|
-
const first = applyPlayerEvent(DEFAULT_STATE, DEFAULT_PROGRESS, 'onError', {
|
|
156
|
-
code: 3001,
|
|
157
|
-
codeName: 'E_LOAD_FAILED',
|
|
158
|
-
recoverable: false,
|
|
159
|
-
message: 'failed to load',
|
|
160
|
-
});
|
|
161
|
-
const second = applyPlayerEvent(first.state, first.progress, 'onError', {
|
|
162
|
-
code: 3005,
|
|
163
|
-
codeName: 'E_UNKNOWN_FORMAT',
|
|
164
|
-
recoverable: false,
|
|
165
|
-
message: 'unknown format',
|
|
166
|
-
});
|
|
167
|
-
expect(second.state.error?.code).toBe(3005);
|
|
168
|
-
expect(second.state.error?.message).toBe('unknown format');
|
|
169
|
-
});
|
|
170
|
-
});
|