@applicaster/zapp-react-native-ui-components 16.0.0-rc.96 → 16.0.0-rc.97

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.
@@ -213,10 +213,16 @@ export class LiveImageManager implements PlayerLifecycleListener {
213
213
  log_debug(
214
214
  `pauseItem: live-image not ready, ${item.playerId} - ${item.tag}`
215
215
  );
216
- } else {
217
- item.player.pause();
218
216
  }
219
217
 
218
+ // Pause even when the player is not ready yet: the underlying player may
219
+ // still be loading and would otherwise start playing on its own once it
220
+ // has buffered, leaving the live-image audible underneath the primary
221
+ // player. Note this is best effort - the web controller's pause() only
222
+ // logs while the player component is unmounted - so the player itself also
223
+ // refuses buffer-driven starts when it was never asked to play.
224
+ item.player.pause();
225
+
220
226
  // Fake close event, because we unmount native view
221
227
  item.player.onPlayerClose();
222
228
  item.setMode?.(LiveImageType.Image);
@@ -1,6 +1,8 @@
1
1
  const { LiveImageManager } = require("../LiveImageManager");
2
2
 
3
3
  describe("LiveImageManager", () => {
4
+ const flushPromises = () => new Promise(setImmediate);
5
+
4
6
  it("should subscribe to LiveImageManager events", () => {
5
7
  const sampleListener = {
6
8
  id: "1",
@@ -78,4 +80,61 @@ describe("LiveImageManager", () => {
78
80
  expect(mockOnEnd1).toHaveBeenCalledWith(eventBody);
79
81
  expect(mockOnEnd2).toHaveBeenCalledWith(eventBody);
80
82
  });
83
+
84
+ it("should start a prepared live image when the mounted player loads", async () => {
85
+ const manager = new LiveImageManager();
86
+
87
+ const item = {
88
+ playerId: "live-image",
89
+ tag: "Live image",
90
+ player: {
91
+ playerId: "live-image",
92
+ playerState: { isReadyToPlay: false },
93
+ getEntry: jest.fn(),
94
+ play: jest.fn(),
95
+ },
96
+ getPlayer: jest.fn(),
97
+ prepareForPlayback: jest.fn().mockResolvedValue(true),
98
+ setMode: jest.fn(),
99
+ };
100
+
101
+ manager.playLiveImage(item);
102
+ await flushPromises();
103
+
104
+ expect(item.setMode).toHaveBeenCalledWith("video");
105
+ expect(item.player.play).not.toHaveBeenCalled();
106
+
107
+ manager.onLiveImageVideoLoaded(item);
108
+
109
+ expect(item.player.play).toHaveBeenCalledTimes(1);
110
+ });
111
+
112
+ it("should not start a live image that was paused before the player loaded", async () => {
113
+ const manager = new LiveImageManager();
114
+
115
+ const item = {
116
+ playerId: "live-image",
117
+ tag: "Live image",
118
+ player: {
119
+ playerId: "live-image",
120
+ playerState: { isReadyToPlay: false },
121
+ getEntry: jest.fn(),
122
+ play: jest.fn(),
123
+ pause: jest.fn(),
124
+ onPlayerClose: jest.fn(),
125
+ },
126
+ getPlayer: jest.fn(),
127
+ prepareForPlayback: jest.fn().mockResolvedValue(true),
128
+ setMode: jest.fn(),
129
+ };
130
+
131
+ manager.playLiveImage(item);
132
+ await flushPromises();
133
+ manager.pauseLiveImage(item);
134
+ manager.onLiveImageVideoLoaded(item);
135
+
136
+ expect(item.player.pause).toHaveBeenCalledTimes(1);
137
+ expect(item.player.play).not.toHaveBeenCalled();
138
+ expect(item.setMode).toHaveBeenLastCalledWith("image");
139
+ });
81
140
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applicaster/zapp-react-native-ui-components",
3
- "version": "16.0.0-rc.96",
3
+ "version": "16.0.0-rc.97",
4
4
  "description": "Applicaster Zapp React Native ui components for the Quick Brick App",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -28,10 +28,10 @@
28
28
  },
29
29
  "homepage": "https://github.com/applicaster/quickbrick#readme",
30
30
  "dependencies": {
31
- "@applicaster/applicaster-types": "16.0.0-rc.96",
32
- "@applicaster/zapp-react-native-bridge": "16.0.0-rc.96",
33
- "@applicaster/zapp-react-native-redux": "16.0.0-rc.96",
34
- "@applicaster/zapp-react-native-utils": "16.0.0-rc.96",
31
+ "@applicaster/applicaster-types": "16.0.0-rc.97",
32
+ "@applicaster/zapp-react-native-bridge": "16.0.0-rc.97",
33
+ "@applicaster/zapp-react-native-redux": "16.0.0-rc.97",
34
+ "@applicaster/zapp-react-native-utils": "16.0.0-rc.97",
35
35
  "fast-json-stable-stringify": "^2.1.0",
36
36
  "promise": "^8.3.0",
37
37
  "react-native-sortables": "1.7.1",