@bits-innovate/react-native-vstarcam 1.0.61 → 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.
@@ -933,6 +933,34 @@ public class VStarCamModule extends ReactContextBaseJavaModule implements Lifecy
933
933
  }
934
934
  }
935
935
 
936
+ /**
937
+ * Mute / Unmute the Live Video Stream Audio
938
+ */
939
+ @ReactMethod
940
+ public void setAudioStream(int clientPtr, boolean enableAudio, Promise promise) {
941
+ Log.d(TAG, "setAudioStream called: client=" + clientPtr + ", enable=" + enableAudio);
942
+ try {
943
+ ClientInfo clientInfo = clients.get(clientPtr);
944
+ if (clientInfo == null || clientInfo.sdkClientPtr == 0) {
945
+ promise.reject("E_NOT_CONNECTED", "Client not connected");
946
+ return;
947
+ }
948
+
949
+ // Find AppPlayerApi class
950
+ Class<?> appPlayerClass = Class.forName("com.veepai.AppPlayerApi");
951
+ Method setAudioMethod = appPlayerClass.getMethod("app_player_set_audio", long.class, int.class);
952
+
953
+ // Invoke app_player_set_audio(clientPtr, onOff) where 1=ON, 0=OFF
954
+ int result = (Integer) setAudioMethod.invoke(null, clientInfo.sdkClientPtr, enableAudio ? 1 : 0);
955
+ Log.d(TAG, "app_player_set_audio result: " + result);
956
+
957
+ promise.resolve(result == 0); // usually 0 is success
958
+ } catch (Exception e) {
959
+ Log.e(TAG, "setAudioStream error", e);
960
+ promise.reject("E_AUDIO_SET_FAILED", e.getMessage(), e);
961
+ }
962
+ }
963
+
936
964
  /**
937
965
  * Check connection mode
938
966
  * JNIApi.checkMode(long clientPtr)
@@ -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.61",
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",
@@ -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 */