capacitor-plugin-vonage 0.0.7 → 0.0.9

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.
@@ -14,7 +14,7 @@ Pod::Spec.new do |s|
14
14
  s.ios.deployment_target = '13.0'
15
15
  s.dependency 'Capacitor'
16
16
  #s.dependency 'OpenTok','2.25.0'
17
- s.dependency 'OTXCFramework','2.26.2'
17
+ s.dependency 'OTXCFramework','2.27.0'
18
18
  s.swift_version = '5.1'
19
19
  s.static_framework = true
20
20
  end
@@ -1,6 +1,7 @@
1
1
  <manifest xmlns:android="http://schemas.android.com/apk/res/android">
2
2
  <application>
3
3
  <activity android:name="com.managemyhealth.plugin.vonage.VideoCallActivity"
4
+ android:launchMode="singleTask"
4
5
  android:screenOrientation="portrait">
5
6
  </activity>
6
7
  </application>
@@ -57,6 +57,7 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
57
57
 
58
58
  public Session session;
59
59
  private static Bridge staticBridge = null;
60
+ private String dummyProfile = "https://www.gravatar.com/avatar/?d=mp";
60
61
 
61
62
  public static VideoCallActivity instance;
62
63
  private Publisher publisher;
@@ -137,88 +138,63 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
137
138
  private final Session.SessionListener sessionListener = new Session.SessionListener() {
138
139
  @Override
139
140
  public void onConnected(Session session) {
140
- Log.d(TAG, "onConnected: Connected to session: " + session.getSessionId());
141
- // JSObject eventData = new JSObject();
142
- // eventData.put("key", "value");
143
- // notifyListeners("", eventData);
144
141
  publisher = new Publisher.Builder(VideoCallActivity.this).build();
145
142
  publisher.setPublisherListener(publisherListener);
146
143
  publisher.getRenderer().setStyle(BaseVideoRenderer.STYLE_VIDEO_SCALE, BaseVideoRenderer.STYLE_VIDEO_FILL);
147
- Log.d("publisherViewContainer", "publisherViewContainer.toString()");
148
144
  FrameLayout Framelayout = findViewById(R.id.publisher_container);
149
-
150
145
  try {
151
146
  if (Framelayout != null) {
152
- Log.d("publisherViewContainer", "Inside if =======");
153
147
  Framelayout.addView(publisher.getView());
154
148
  }
155
- } catch (Exception e) {
156
- Log.d("publisherViewContainer", e.toString());
157
- }
158
-
149
+ } catch (Exception e) {}
159
150
  if (publisher.getView() instanceof GLSurfaceView) {
160
151
  ((GLSurfaceView) publisher.getView()).setZOrderOnTop(true);
161
152
  }
162
-
163
153
  session.publish(publisher);
164
154
  }
165
-
166
155
  @Override
167
156
  public void onDisconnected(Session session) {
168
157
  notifyObservers("deny");
169
158
  if(publisher!=null) {
170
-
171
159
  publisher.setPublishAudio(false);
172
160
  imageViewMute.setImageResource(R.drawable.microphoneoff);
173
-
174
161
  }
175
162
  if(publisher!=null) {
176
-
177
163
  publisher.setPublishVideo(false);
178
164
  imageViewCamOff.setImageResource(R.drawable.cameraoff);
179
165
  imageViewCamSwitch.setVisibility(View.GONE);
180
-
181
-
182
-
183
166
  }
184
167
  VideoCallActivity temp = new VideoCallActivity();
185
168
  temp.session = null;
186
-
187
- isTimeron=false;
188
-
189
- Log.d(TAG, "onDisconnected: Disconnected from session: " + session.getSessionId());
190
- if (publisher != null) {
169
+ isTimeron=false;
170
+ if (publisher != null) {
191
171
  publisher = null;
192
172
  publisherViewContainer.removeAllViews();
193
173
  }
194
- Intent resultIntent = new Intent();
195
- String resultcode = "";
196
-
197
- if(isEndall){
198
- resultcode= "111";
199
- }else{
200
- resultcode = ISPROVIDER ? "999" : "888";
201
- }
202
- resultIntent.putExtra("result_key", resultcode);
203
- setResult(RESULT_OK, resultIntent);
204
- // setResult(RESULT_CANCELED); // Use this to indicate cancellation
205
-
206
-
207
- finish();
174
+ Intent resultIntent = new Intent();
175
+ String resultcode = "";
176
+ if(isEndall){
177
+ resultcode= "111";
178
+ }else{
179
+ resultcode = ISPROVIDER ? "999" : "888";
180
+ }
181
+ resultIntent.putExtra("result_key", resultcode);
182
+ setResult(RESULT_OK, resultIntent);
183
+ finish();
208
184
  }
209
-
210
185
  @Override
211
186
  public void onStreamReceived(Session session, Stream stream) {
212
187
 
213
- Log.d(TAG, "onStreamReceived: New Stream Received " + stream.getStreamId() + " in session: " + session.getSessionId());
214
188
  ProviderViewLayout = findViewById(R.id.providerViewLayout);
215
189
  if(ISPROVIDER) {
216
190
  ProviderViewLayout.setVisibility(View.VISIBLE);
217
191
  }
218
192
  circleAvatar.setVisibility(View.GONE); // Hide the view
219
193
  patientStatus.setVisibility(View.GONE); // Hide the view
220
- publishernameView.setVisibility(View.GONE); // Hide the view
221
-
194
+ publishernameView.setVisibility(View.GONE);// Hide the view
195
+ admit.setVisibility(View.GONE);
196
+ deny.setVisibility(View.GONE);
197
+ sendNotifications.setVisibility(View.GONE);
222
198
 
223
199
  if (subscriber == null) {
224
200
  subscriber = new Subscriber.Builder(VideoCallActivity.this, stream).build();
@@ -228,22 +204,14 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
228
204
  session.subscribe(subscriber);
229
205
  try {
230
206
  subscriberViewContainer.addView(subscriber.getView());
231
- } catch (Exception e) {
232
- Log.d("subscriberViewContainer", e.toString());
233
-
234
- }
207
+ } catch (Exception e) {}
235
208
  showToast(SUBSCRIBERNAME + "joined the call");
236
-
237
209
  }
238
210
  }
239
211
 
240
212
  @Override
241
213
  public void onStreamDropped(Session session, Stream stream) {
242
-
243
- Log.d(TAG, "onStreamDropped: Stream Dropped: " + stream.getStreamId() + " in session: " + session.getSessionId());
244
-
245
- circleAvatar.setVisibility(View.VISIBLE); // Show the view
246
-
214
+ circleAvatar.setVisibility(View.VISIBLE); // Show the view
247
215
  if(!ISPROVIDER){
248
216
  if(session!=null){
249
217
  session.disconnect();
@@ -273,6 +241,20 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
273
241
  finishWithMessage("Session error: " + opentokError.getMessage());
274
242
  }
275
243
  };
244
+ SubscriberKit.AudioStatsListener aaa = new SubscriberKit.AudioStatsListener(){
245
+ @Override
246
+ public void onAudioStats(SubscriberKit subscriberKit, SubscriberKit.SubscriberAudioStats subscriberAudioStats) {
247
+
248
+ }
249
+ };
250
+ SubscriberKit.AudioLevelListener sss = new SubscriberKit.AudioLevelListener(){
251
+
252
+ @Override
253
+ public void onAudioLevelUpdated(SubscriberKit subscriberKit, float v) {
254
+
255
+ }
256
+ };
257
+
276
258
  SubscriberKit.VideoListener videoListener = new SubscriberKit.VideoListener() {
277
259
 
278
260
  @Override
@@ -424,7 +406,8 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
424
406
  }else{
425
407
  ProviderViewLayout.setVisibility(View.GONE);
426
408
  }
427
- new urltoSource((ImageView) findViewById(R.id.image_view)).execute(profilePicApiUrl);
409
+ String dummyImage = profilePicApiUrl.length()>10?profilePicApiUrl:dummyProfile;
410
+ new urltoSource((ImageView) findViewById(R.id.image_view)).execute(dummyImage);
428
411
  initializeSession(API_KEY,SESSION_ID , TOKEN);
429
412
 
430
413
  }
@@ -474,8 +457,6 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
474
457
  if(session!=null){
475
458
  session.disconnect();
476
459
  }
477
- // session.cl=
478
-
479
460
  }
480
461
  });
481
462
 
@@ -50,9 +50,10 @@ public class vonagePlugin extends Plugin{
50
50
  @PluginMethod(returnType = PluginMethod.RETURN_CALLBACK)
51
51
  public void setPatientOnlineStatus(PluginCall call) {
52
52
  final Boolean isOnline = call.getBoolean("isOnline");
53
-
53
+ showLog("isOnline");
54
+ showLog(isOnline.toString());
54
55
  Handler mainHandler = new Handler(Looper.getMainLooper());
55
- Context appCon = this.bridge.getContext();
56
+
56
57
  Runnable myRunnable = new Runnable() {
57
58
  @Override
58
59
  public void run() {
@@ -121,6 +122,8 @@ public class vonagePlugin extends Plugin{
121
122
  intent.putExtra("isProvider", ISPROVIDER);
122
123
  intent.putExtra("isPatientOnline", isPatientOnline);
123
124
  intent.putExtra("profilePicApiUrl", profilePicApiUrl);
125
+ intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP|Intent.FLAG_ACTIVITY_SINGLE_TOP);
126
+
124
127
 
125
128
  Handler handler = new Handler();
126
129
  int delayMillis = 2000;
@@ -134,7 +137,7 @@ public class vonagePlugin extends Plugin{
134
137
  }, delayMillis);
135
138
 
136
139
  eventData.put("isProvider", isProvid);
137
- showLog("testing resolve endPluginCal");
140
+
138
141
  endPluginCal.resolve(eventData);
139
142
  this.startActivityForResult(call, intent, "onAcitivtyClosed");
140
143
  call.setKeepAlive(false);
@@ -148,8 +151,7 @@ public class vonagePlugin extends Plugin{
148
151
  JSObject eventData1 = new JSObject();
149
152
  eventData1.put("key", "value test value");
150
153
  eventData1.put("isProvider", isProvid);
151
- showLog("eventData");
152
- showLog(eventData1.toString());
154
+
153
155
  handler.postDelayed(new Runnable() {
154
156
  @Override
155
157
  public void run() {
@@ -238,7 +240,7 @@ public class vonagePlugin extends Plugin{
238
240
  // session.connect(token);
239
241
  // }
240
242
  private void showLog(String log){
241
- Log.d(Tag,log);
243
+ // Log.d(Tag,log);
242
244
  }
243
245
  private void test(PluginCall call){
244
246
  JSObject eventData = new JSObject();
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -58,7 +58,7 @@
58
58
  android:layout_height="wrap_content"
59
59
  android:layout_gravity="bottom|start"
60
60
  android:paddingBottom="100dp"
61
- android:paddingLeft="10dp"
61
+ android:paddingStart="10dp"
62
62
  android:text="00:00:00"
63
63
  android:visibility="visible"
64
64
  android:textColor="@android:color/white"
@@ -70,10 +70,8 @@
70
70
  android:layout_height="120dp"
71
71
  android:layout_gravity="bottom|end"
72
72
  android:layout_marginEnd="16dp"
73
- android:layout_marginRight="16dp"
74
73
  android:layout_marginBottom="80dp"
75
74
  android:background="#9b9c98"
76
- android:layout_below="@id/publisherName"
77
75
 
78
76
  android:padding="2dp" >
79
77
  <TextView
File without changes
File without changes
File without changes
@@ -48,7 +48,7 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
48
48
  var timerLabel = UILabel()
49
49
  var subscriberImg = UIImageView()
50
50
  var counter = 0
51
- var timer = Timer()
51
+ var timer : Timer?
52
52
  var activityView: UIActivityIndicatorView?
53
53
  override func viewDidLoad() {
54
54
 
@@ -104,16 +104,7 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
104
104
  NotificationCenter.default.addObserver(self, selector: #selector(deviceOrientationDidChange), name: UIDevice.orientationDidChangeNotification, object: nil)
105
105
  NotificationCenter.default.addObserver(self, selector: #selector(setPatientOnlineStatus), name: NSNotification.Name ("PatientOnlineStatus"), object: nil)
106
106
  NotificationCenter.default.addObserver(self,selector:#selector(endVideoCall(_:)),name: NSNotification.Name ("EndVideoCall"),object: nil)
107
- // DispatchQueue.main.asyncAfter(deadline: .now() + 1.0, execute: {
108
- //
109
- // self.connectToAnOpenTokSession()
110
- // })
111
- // if(isVideoMute){
112
- // subscriberImg.isHidden = true
113
- // }else{
114
- // subscriberImg.isHidden = false
115
- // }
116
- // turnOnAndOffVideo()
107
+
117
108
  }
118
109
  func showActivityIndicator() {
119
110
  activityView = UIActivityIndicatorView(style: .large)
@@ -132,11 +123,14 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
132
123
  print("viewDidDisappear")
133
124
  super.viewDidDisappear(animated)
134
125
  let userInfo = ["userInfo": ["isProvider": self.isProvider]]
135
- NotificationCenter.default.post(name: NSNotification.Name(NotificationNames.videoEnded),object: nil,userInfo: userInfo)
136
-
137
- // NotificationCenter.default.removeObserver(self, name: NSNotification.Name("EndVideoCall"), object: nil)
126
+ if(!isCallEnded){
127
+ NotificationCenter.default.post(name: NSNotification.Name(NotificationNames.videoEnded),object: nil,userInfo: userInfo)
128
+
129
+ // NotificationCenter.default.removeObserver(self, name: NSNotification.Name("EndVideoCall"), object: nil)
130
+
131
+ NotificationCenter.default.post(name: NSNotification.Name("RemoveObservers"),object: nil,userInfo: userInfo)
132
+ }
138
133
  NotificationCenter.default.removeObserver(self)
139
- NotificationCenter.default.post(name: NSNotification.Name("RemoveObservers"),object: nil,userInfo: userInfo)
140
134
  }
141
135
  @objc func appMovedToBackground() {
142
136
  print("App moved to background!")
@@ -177,13 +171,23 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
177
171
  NotificationCenter.default.removeObserver(self, name: NSNotification.Name("EndVideoCall"), object: nil)
178
172
  }
179
173
  func startTimer(){
180
- timer.invalidate()
174
+ // if(timer != nil && timer.isValid){
175
+ // timer.invalidate()
176
+ // }
177
+ if let timerObj = timer, timerObj.isValid{
178
+ timer?.invalidate()
179
+ }
181
180
  timer = Timer.scheduledTimer(timeInterval: 1.0, target: self, selector: #selector(timerAction), userInfo: nil, repeats: true)
182
181
  }
183
182
  func stopTimer(){
184
- if(timer.isValid){
185
- timer.invalidate()
183
+ // if(timer != nil && timer.isValid){
184
+ // timer.invalidate()
185
+ // counter = 0
186
+ // }
187
+ if let timerObj = timer, timerObj.isValid{
188
+ timer?.invalidate()
186
189
  counter = 0
190
+ timer = nil
187
191
  }
188
192
 
189
193
  }
@@ -440,10 +444,11 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
440
444
  let userInfo = ["userInfo": ["isProvider": isProvider]]
441
445
 
442
446
  NotificationCenter.default.post(name: NSNotification.Name(NotificationNames.videoEnded),object: nil,userInfo: userInfo)
443
- self.session?.disconnect(nil)
444
- self.stopTimer()
445
- self.dismiss(animated: true, completion: nil)
446
- NotificationCenter.default.post(name: NSNotification.Name("RemoveObservers"),object: nil,userInfo: userInfo)
447
+ // self.session?.disconnect(nil)
448
+ // self.stopTimer()
449
+ // self.dismiss(animated: true, completion: nil)
450
+ // NotificationCenter.default.post(name: NSNotification.Name("RemoveObservers"),object: nil,userInfo: userInfo)
451
+ self.endVonageCall()
447
452
  }
448
453
 
449
454
  @objc func callBtnbuttonClicked() {
@@ -565,6 +570,9 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
565
570
  return
566
571
  }
567
572
 
573
+ if !stream.hasAudio {
574
+ print("Stream audio \(stream.hasAudio)")
575
+ }
568
576
  self.subscriber = subscriber
569
577
  var error: OTError?
570
578
  session.subscribe(subscriber, error: &error)
@@ -685,12 +693,10 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
685
693
  NotificationCenter.default.post(name: NSNotification.Name("RemoveObservers"),object: nil,userInfo: userInfo)
686
694
  DispatchQueue.main.async {
687
695
  print("video ended called")
688
- self.session?.disconnect(nil)
689
-
690
696
  // self.publisher?.publishVideo = false
691
697
  self.publisher?.videoCapture?.stop()
692
698
  // self.publisher?.publishAudio = false
693
-
699
+ self.session?.disconnect(nil)
694
700
  self.cleanupSubscriber()
695
701
  self.cleanupPublisher()
696
702
  self.stopTimer()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "capacitor-plugin-vonage",
3
- "version": "0.0.7",
3
+ "version": "0.0.9",
4
4
  "description": "opentok sdk capacitor plugin",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",