@bits-innovate/react-native-vstarcam 1.0.62 → 1.0.64

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.
@@ -48,6 +48,7 @@ public class VStarCamVideoView extends FrameLayout
48
48
  private boolean playerInitialized = false;
49
49
  private boolean pendingStartStream = false;
50
50
  private boolean streamingRequested = false; // Tracks if JS set streaming=true
51
+ private boolean audioEnabled = false; // Track requested audio state
51
52
 
52
53
  // Player class (from AAR)
53
54
  private Class<?> appPlayerClass;
@@ -173,6 +174,28 @@ public class VStarCamVideoView extends FrameLayout
173
174
  Log.d(TAG, "Resolution set: " + res);
174
175
  }
175
176
 
177
+ /**
178
+ * Enable or disable livestream audio playback.
179
+ */
180
+ public void setAudioEnabled(boolean enable) {
181
+ this.audioEnabled = enable;
182
+ if (playerPtr != 0 && isStreaming) {
183
+ try {
184
+ if (enable) {
185
+ Method startVoice = appPlayerClass.getMethod("startVoice", long.class);
186
+ startVoice.invoke(null, playerPtr);
187
+ Log.d(TAG, "Audio started");
188
+ } else {
189
+ Method stopVoice = appPlayerClass.getMethod("stopVoice", long.class);
190
+ stopVoice.invoke(null, playerPtr);
191
+ Log.d(TAG, "Audio stopped");
192
+ }
193
+ } catch (Exception e) {
194
+ Log.e(TAG, "Failed to set audio. Method missing?", e);
195
+ }
196
+ }
197
+ }
198
+
176
199
  /**
177
200
  * Start video streaming.
178
201
  * Uses AppPlayerApi methods discovered via reflection:
@@ -222,7 +245,8 @@ public class VStarCamVideoView extends FrameLayout
222
245
 
223
246
  Method createPlayerMethod = appPlayerClass.getMethod(
224
247
  "createPlayer", long.class, Surface.class, int.class, int.class, int.class);
225
- Object result = createPlayerMethod.invoke(null, 0L, surface, width, height, 0);
248
+ // The 5th parameter appears to be audio rate. The Flutter SDK uses 8000.
249
+ Object result = createPlayerMethod.invoke(null, 0L, surface, width, height, 8000);
226
250
  playerPtr = (Long) result;
227
251
  sendErrorEvent("Player created: ptr=" + playerPtr + " size=" + width + "x" + height);
228
252
  }
@@ -248,6 +272,9 @@ public class VStarCamVideoView extends FrameLayout
248
272
  playerInitialized = true;
249
273
  statusView.setVisibility(GONE);
250
274
 
275
+ // Sync audio state now that streaming has started
276
+ setAudioEnabled(this.audioEnabled);
277
+
251
278
  // Send success event to JS
252
279
  try {
253
280
  com.facebook.react.bridge.WritableMap event =
@@ -69,6 +69,14 @@ public class VStarCamVideoViewManager extends SimpleViewManager<VStarCamVideoVie
69
69
  }
70
70
  }
71
71
 
72
+ /**
73
+ * Control audio listening via prop
74
+ */
75
+ @ReactProp(name = "audioEnabled", defaultBoolean = false)
76
+ public void setAudioEnabled(VStarCamVideoView view, boolean audioEnabled) {
77
+ view.setAudioEnabled(audioEnabled);
78
+ }
79
+
72
80
  /**
73
81
  * Commands that can be called from JS via dispatchViewManagerCommand
74
82
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bits-innovate/react-native-vstarcam",
3
- "version": "1.0.62",
3
+ "version": "1.0.64",
4
4
  "description": "React Native bridge for VStarCam P2P SDK",
5
5
  "main": "src/index.ts",
6
6
  "types": "src/index.ts",
@@ -43,4 +43,4 @@
43
43
  "react": "*",
44
44
  "react-native": "*"
45
45
  }
46
- }
46
+ }
package/src/index.ts CHANGED
@@ -29,6 +29,8 @@ export interface VStarCamVideoViewProps {
29
29
  resolution?: 1 | 2 | 4 | 100;
30
30
  /** Whether streaming is active */
31
31
  streaming?: boolean;
32
+ /** Whether live audio should play (unmuted) */
33
+ audioEnabled?: boolean;
32
34
  /** Style for the video view */
33
35
  style?: ViewStyle;
34
36
  /** Called when stream starts */
@@ -320,15 +322,6 @@ class VStarCamClient {
320
322
  return VStarCamModule.clientGetState(this.clientPtr);
321
323
  }
322
324
 
323
- /**
324
- * Mutes or Unmutes the live video audio stream
325
- * @param enableAudio true to play sound, false to mute
326
- */
327
- async setAudioStream(enableAudio: boolean): Promise<boolean> {
328
- if (!this.clientPtr) throw new Error("Client not created");
329
- return VStarCamModule.setAudioStream(this.clientPtr, enableAudio);
330
- }
331
-
332
325
  /**
333
326
  * Login to the camera
334
327
  * @param username Camera username (default: admin)