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

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:
@@ -248,6 +271,9 @@ public class VStarCamVideoView extends FrameLayout
248
271
  playerInitialized = true;
249
272
  statusView.setVisibility(GONE);
250
273
 
274
+ // Sync audio state now that streaming has started
275
+ setAudioEnabled(this.audioEnabled);
276
+
251
277
  // Send success event to JS
252
278
  try {
253
279
  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.63",
4
4
  "description": "React Native bridge for VStarCam P2P SDK",
5
5
  "main": "src/index.ts",
6
6
  "types": "src/index.ts",
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)