capacitor-plugin-vonage 0.0.2 → 0.0.4
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.
- package/README.md +12 -0
- package/android/build.gradle +1 -2
- package/android/src/main/AndroidManifest.xml +2 -1
- package/android/src/main/java/com/managemyhealth/plugin/vonage/VideoCallActivity.java +145 -26
- package/android/src/main/java/com/managemyhealth/plugin/vonage/vonage.java +0 -0
- package/android/src/main/java/com/managemyhealth/plugin/vonage/vonagePlugin.java +50 -14
- package/android/src/main/res/.gitkeep +0 -0
- package/android/src/main/res/drawable/callend.png +0 -0
- package/android/src/main/res/drawable/callstart.png +0 -0
- package/android/src/main/res/drawable/cameraoff.png +0 -0
- package/android/src/main/res/drawable/cameraonwhite.png +0 -0
- package/android/src/main/res/drawable/cameraswitch.png +0 -0
- package/android/src/main/res/drawable/ic_launcher_background.xml +0 -0
- package/android/src/main/res/drawable/microphoneoff.png +0 -0
- package/android/src/main/res/drawable/microphoneonwhite.png +0 -0
- package/android/src/main/res/layout/activity_main.xml +0 -0
- package/android/src/main/res/layout/video_call_layout.xml +49 -18
- package/android/src/main/res.zip +0 -0
- package/dist/docs.json +10 -0
- package/dist/esm/definitions.d.ts +3 -0
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/web.d.ts +3 -0
- package/dist/esm/web.js +4 -0
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +4 -0
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +4 -0
- package/dist/plugin.js.map +1 -1
- package/ios/Plugin/VideoChatViewController.swift +69 -12
- package/ios/Plugin/vonagePlugin.m +1 -0
- package/ios/Plugin/vonagePlugin.swift +4 -0
- package/package.json +1 -1
package/README.md
CHANGED
@@ -15,6 +15,7 @@ npx cap sync
|
|
15
15
|
|
16
16
|
* [`echo(...)`](#echo)
|
17
17
|
* [`openVideoCallWindow(...)`](#openvideocallwindow)
|
18
|
+
* [`endVideoCall()`](#endvideocall)
|
18
19
|
* [`addListener([eventName: 'VideoCallEnded', listenerFunc: (info: any) => void] | [eventName: 'VideoCallStarted', listenerFunc: (info: any) => void], ...)`](#addlistenereventname-videocallended-listenerfunc-info-any--void--eventname-videocallstarted-listenerfunc-info-any--void)
|
19
20
|
* [Interfaces](#interfaces)
|
20
21
|
* [Type Aliases](#type-aliases)
|
@@ -54,6 +55,17 @@ openVideoCallWindow(options: Object) => Promise<{ value: any; }>
|
|
54
55
|
--------------------
|
55
56
|
|
56
57
|
|
58
|
+
### endVideoCall()
|
59
|
+
|
60
|
+
```typescript
|
61
|
+
endVideoCall() => Promise<{ value: string; }>
|
62
|
+
```
|
63
|
+
|
64
|
+
**Returns:** <code>Promise<{ value: string; }></code>
|
65
|
+
|
66
|
+
--------------------
|
67
|
+
|
68
|
+
|
57
69
|
### addListener([eventName: 'VideoCallEnded', listenerFunc: (info: any) => void] | [eventName: 'VideoCallStarted', listenerFunc: (info: any) => void], ...)
|
58
70
|
|
59
71
|
```typescript
|
package/android/build.gradle
CHANGED
@@ -51,7 +51,6 @@ repositories {
|
|
51
51
|
dependencies {
|
52
52
|
implementation 'com.google.android.material:material:1.4.0'
|
53
53
|
implementation 'pub.devrel:easypermissions:3.0.0'
|
54
|
-
implementation 'com.opentok.android:opentok-android-sdk:2.22.0'
|
55
54
|
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
56
55
|
implementation project(':capacitor-android')
|
57
56
|
implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
|
@@ -62,7 +61,7 @@ dependencies {
|
|
62
61
|
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
63
62
|
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
|
64
63
|
implementation 'androidx.annotation:annotation:1.7.0'
|
65
|
-
implementation 'com.opentok.android:opentok-android-sdk:2.
|
64
|
+
implementation 'com.opentok.android:opentok-android-sdk:2.26.2'
|
66
65
|
androidTestImplementation 'androidx.test:runner:1.5.2'
|
67
66
|
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
|
68
67
|
|
@@ -1,6 +1,7 @@
|
|
1
1
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
2
2
|
<application>
|
3
|
-
<activity android:name="com.managemyhealth.plugin.vonage.VideoCallActivity"
|
3
|
+
<activity android:name="com.managemyhealth.plugin.vonage.VideoCallActivity"
|
4
|
+
android:screenOrientation="portrait">
|
4
5
|
</activity>
|
5
6
|
</application>
|
6
7
|
</manifest>
|
@@ -1,9 +1,12 @@
|
|
1
1
|
package com.managemyhealth.plugin.vonage;
|
2
2
|
|
3
3
|
|
4
|
-
|
4
|
+
import android.annotation.SuppressLint;
|
5
|
+
import android.os.AsyncTask;
|
5
6
|
import android.app.ActionBar;
|
6
7
|
import android.content.Intent;
|
8
|
+
import android.graphics.Bitmap;
|
9
|
+
import android.graphics.BitmapFactory;
|
7
10
|
import android.nfc.Tag;
|
8
11
|
import android.opengl.GLSurfaceView;
|
9
12
|
import android.os.Bundle;
|
@@ -32,6 +35,7 @@ import com.opentok.android.SubscriberKit;
|
|
32
35
|
//import com.tokbox.sample.basicvideochat.network.APIService;
|
33
36
|
//import com.tokbox.sample.basicvideochat.network.GetSessionResponse;
|
34
37
|
|
38
|
+
import java.io.InputStream;
|
35
39
|
import java.util.List;
|
36
40
|
|
37
41
|
import okhttp3.OkHttpClient;
|
@@ -47,11 +51,14 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
|
|
47
51
|
private static final String TAG = VideoCallActivity.class.getSimpleName();
|
48
52
|
private static final int PERMISSIONS_REQUEST_CODE = 124;
|
49
53
|
|
50
|
-
|
54
|
+
public Session session;
|
51
55
|
private Publisher publisher;
|
56
|
+
String SUBSCRIBERNAME ;
|
57
|
+
String PUBLISHERNAME;
|
52
58
|
boolean isMuted = false;
|
53
59
|
boolean isCamOff = false;
|
54
60
|
boolean isTimeron = false;
|
61
|
+
boolean isEndall = false;
|
55
62
|
private Subscriber subscriber;
|
56
63
|
private FrameLayout publisherViewContainer;
|
57
64
|
private FrameLayout subscriberViewContainer;
|
@@ -79,12 +86,12 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
|
|
79
86
|
public void onError(PublisherKit publisherKit, OpentokError opentokError) {
|
80
87
|
finishWithMessage("PublisherKit onError: " + opentokError.getMessage());
|
81
88
|
}
|
89
|
+
|
82
90
|
};
|
83
91
|
|
84
92
|
private final Session.SessionListener sessionListener = new Session.SessionListener() {
|
85
93
|
@Override
|
86
94
|
public void onConnected(Session session) {
|
87
|
-
|
88
95
|
Log.d(TAG, "onConnected: Connected to session: " + session.getSessionId());
|
89
96
|
// JSObject eventData = new JSObject();
|
90
97
|
// eventData.put("key", "value");
|
@@ -121,8 +128,14 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
|
|
121
128
|
publisherViewContainer.removeAllViews();
|
122
129
|
}
|
123
130
|
Intent resultIntent = new Intent();
|
124
|
-
String resultcode =
|
125
|
-
|
131
|
+
String resultcode = "";
|
132
|
+
|
133
|
+
if(isEndall){
|
134
|
+
resultcode= "111";
|
135
|
+
}else{
|
136
|
+
resultcode = ISPROVIDER ? "999" : "888";
|
137
|
+
}
|
138
|
+
resultIntent.putExtra("result_key", resultcode);
|
126
139
|
setResult(RESULT_OK, resultIntent);
|
127
140
|
// setResult(RESULT_CANCELED); // Use this to indicate cancellation
|
128
141
|
|
@@ -132,12 +145,14 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
|
|
132
145
|
|
133
146
|
@Override
|
134
147
|
public void onStreamReceived(Session session, Stream stream) {
|
148
|
+
|
135
149
|
Log.d(TAG, "onStreamReceived: New Stream Received " + stream.getStreamId() + " in session: " + session.getSessionId());
|
136
150
|
|
137
151
|
if (subscriber == null) {
|
138
152
|
subscriber = new Subscriber.Builder(VideoCallActivity.this, stream).build();
|
139
153
|
subscriber.getRenderer().setStyle(BaseVideoRenderer.STYLE_VIDEO_SCALE, BaseVideoRenderer.STYLE_VIDEO_FILL);
|
140
154
|
subscriber.setSubscriberListener(subscriberListener);
|
155
|
+
subscriber.setVideoListener(videoListener);
|
141
156
|
session.subscribe(subscriber);
|
142
157
|
try {
|
143
158
|
subscriberViewContainer.addView(subscriber.getView());
|
@@ -145,6 +160,8 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
|
|
145
160
|
Log.d("subscriberViewContainer", e.toString());
|
146
161
|
|
147
162
|
}
|
163
|
+
showToast(SUBSCRIBERNAME + "joined the call");
|
164
|
+
|
148
165
|
}
|
149
166
|
}
|
150
167
|
|
@@ -160,20 +177,59 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
|
|
160
177
|
subscriberViewContainer.removeAllViews();
|
161
178
|
Intent resultIntent = new Intent();
|
162
179
|
String resultcode = ISPROVIDER?"999":"888";
|
163
|
-
resultIntent.putExtra("result_key", resultcode);
|
180
|
+
resultIntent.putExtra("result_key", resultcode);
|
164
181
|
setResult(RESULT_OK, resultIntent);
|
165
182
|
finish();
|
166
183
|
}
|
184
|
+
}else{
|
185
|
+
if (subscriber != null) {
|
186
|
+
subscriber = null;
|
187
|
+
subscriberViewContainer.removeAllViews();
|
188
|
+
showToast(SUBSCRIBERNAME + " left the call");
|
189
|
+
|
190
|
+
}
|
167
191
|
}
|
168
192
|
}
|
169
193
|
|
194
|
+
|
170
195
|
@Override
|
171
196
|
public void onError(Session session, OpentokError opentokError) {
|
172
197
|
finishWithMessage("Session error: " + opentokError.getMessage());
|
173
198
|
}
|
174
199
|
};
|
200
|
+
SubscriberKit.VideoListener videoListener = new SubscriberKit.VideoListener() {
|
201
|
+
|
202
|
+
@Override
|
203
|
+
public void onVideoDataReceived(SubscriberKit subscriberKit) {
|
204
|
+
|
205
|
+
}
|
206
|
+
|
207
|
+
@Override
|
208
|
+
public void onVideoDisabled(SubscriberKit subscriberKit, String s) {
|
209
|
+
showToast(SUBSCRIBERNAME + " video disabled");
|
210
|
+
|
211
|
+
}
|
212
|
+
|
213
|
+
@Override
|
214
|
+
public void onVideoEnabled(SubscriberKit subscriberKit, String s) {
|
215
|
+
showToast(SUBSCRIBERNAME + " video enabled");
|
216
|
+
|
217
|
+
|
218
|
+
}
|
219
|
+
|
220
|
+
@Override
|
221
|
+
public void onVideoDisableWarning(SubscriberKit subscriberKit) {
|
222
|
+
|
223
|
+
}
|
224
|
+
|
225
|
+
@Override
|
226
|
+
public void onVideoDisableWarningLifted(SubscriberKit subscriberKit) {
|
227
|
+
|
228
|
+
}
|
229
|
+
};
|
175
230
|
|
176
231
|
SubscriberKit.SubscriberListener subscriberListener = new SubscriberKit.SubscriberListener() {
|
232
|
+
|
177
233
|
@Override
|
178
234
|
public void onConnected(SubscriberKit subscriberKit) {
|
179
235
|
Log.d(TAG, "onConnected: Subscriber connected. Stream: " + subscriberKit.getStream().getStreamId());
|
@@ -182,10 +238,14 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
|
|
182
238
|
@Override
|
183
239
|
public void onDisconnected(SubscriberKit subscriberKit) {
|
184
240
|
Log.d(TAG, "onDisconnected: Subscriber disconnected. Stream: " + subscriberKit.getStream().getStreamId());
|
241
|
+
|
185
242
|
}
|
186
243
|
|
244
|
+
|
245
|
+
|
187
246
|
@Override
|
188
247
|
public void onError(SubscriberKit subscriberKit, OpentokError opentokError) {
|
248
|
+
showToast(SUBSCRIBERNAME + " failed to connect to the call");
|
189
249
|
finishWithMessage("SubscriberKit onError: " + opentokError.getMessage());
|
190
250
|
}
|
191
251
|
};
|
@@ -201,6 +261,13 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
|
|
201
261
|
}
|
202
262
|
}
|
203
263
|
|
264
|
+
@Override
|
265
|
+
public void onBackPressed() {
|
266
|
+
Log.d("onBack","Called===============");
|
267
|
+
session.disconnect();
|
268
|
+
}
|
269
|
+
|
270
|
+
@SuppressLint("MissingInflatedId")
|
204
271
|
@Override
|
205
272
|
protected void onCreate(Bundle savedInstanceState) {
|
206
273
|
|
@@ -208,6 +275,8 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
|
|
208
275
|
|
209
276
|
super.onCreate(savedInstanceState);
|
210
277
|
setContentView(R.layout.video_call_layout);
|
278
|
+
new DownloadImageFromInternet((ImageView) findViewById(R.id.image_view)).execute("https://www.gravatar.com/avatar/?d=mp");
|
279
|
+
|
211
280
|
getSupportActionBar().hide();
|
212
281
|
ActionBar actionBar = getActionBar();
|
213
282
|
if (actionBar != null) {
|
@@ -219,15 +288,15 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
|
|
219
288
|
String TOKEN = intent.getStringExtra("token");
|
220
289
|
String SESSION_ID = intent.getStringExtra("sessionId");
|
221
290
|
String API_KEY = intent.getStringExtra("apiKey");
|
222
|
-
|
223
|
-
|
291
|
+
SUBSCRIBERNAME = intent.getStringExtra("subscriberName");
|
292
|
+
PUBLISHERNAME = intent.getStringExtra("publisherName");
|
224
293
|
ISPROVIDER = intent.getBooleanExtra("isProvider",false);
|
225
294
|
publisherViewContainer = findViewById(R.id.publisher_container);
|
226
295
|
subscriberViewContainer = findViewById(R.id.subscriber_container);
|
227
296
|
TextView publisherNameTextView = findViewById(R.id.publisherName);
|
228
297
|
TextView subscriberNameTextView = findViewById(R.id.subscriberName);
|
229
|
-
publisherNameTextView.setText(
|
230
|
-
subscriberNameTextView.setText(
|
298
|
+
publisherNameTextView.setText(SUBSCRIBERNAME);
|
299
|
+
subscriberNameTextView.setText(PUBLISHERNAME);
|
231
300
|
timerTextView = findViewById(R.id.timerTextView);
|
232
301
|
startTime = System.currentTimeMillis();
|
233
302
|
isTimeron =true;
|
@@ -252,30 +321,34 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
|
|
252
321
|
}
|
253
322
|
});
|
254
323
|
|
255
|
-
imageViewMute.setOnClickListener(new View.OnClickListener() {
|
324
|
+
imageViewMute.setOnClickListener(new View.OnClickListener() {//mute and unmute audio
|
256
325
|
@Override
|
257
326
|
public void onClick(View v) {
|
258
327
|
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
328
|
+
if(publisher!=null) {
|
329
|
+
if (!isMuted) {
|
330
|
+
publisher.setPublishAudio(false);
|
331
|
+
imageViewMute.setImageResource(R.drawable.microphoneoff);
|
332
|
+
} else {
|
333
|
+
publisher.setPublishAudio(true);
|
334
|
+
imageViewMute.setImageResource(R.drawable.microphoneonwhite);
|
335
|
+
}
|
336
|
+
isMuted = !isMuted;
|
265
337
|
}
|
266
|
-
isMuted = !isMuted;
|
267
338
|
|
268
339
|
}
|
269
340
|
});
|
270
|
-
imageViewCamOff.setOnClickListener(new View.OnClickListener() {
|
341
|
+
imageViewCamOff.setOnClickListener(new View.OnClickListener() {//off & on camera
|
271
342
|
@Override
|
272
343
|
public void onClick(View v) {
|
344
|
+
if(publisher!=null) {
|
273
345
|
|
274
346
|
if (!isCamOff) {
|
275
347
|
publisher.setPublishVideo(false);
|
276
348
|
imageViewCamOff.setImageResource(R.drawable.cameraoff);
|
277
349
|
imageViewCamSwitch.setVisibility(View.GONE);
|
278
350
|
|
351
|
+
|
279
352
|
} else {
|
280
353
|
publisher.setPublishVideo(true);
|
281
354
|
imageViewCamOff.setImageResource(R.drawable.cameraonwhite);
|
@@ -285,14 +358,14 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
|
|
285
358
|
isCamOff = !isCamOff;
|
286
359
|
|
287
360
|
}
|
361
|
+
}
|
288
362
|
});
|
289
363
|
imageViewCamSwitch.setOnClickListener(new View.OnClickListener() {
|
290
364
|
@Override
|
291
365
|
public void onClick(View v) {
|
292
|
-
publisher
|
293
|
-
|
294
|
-
|
295
|
-
|
366
|
+
if(publisher!=null) {
|
367
|
+
publisher.cycleCamera();//flip camera
|
368
|
+
}
|
296
369
|
}
|
297
370
|
});
|
298
371
|
|
@@ -316,6 +389,25 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
|
|
316
389
|
session.onResume();
|
317
390
|
}
|
318
391
|
}
|
392
|
+
public void endCall() {
|
393
|
+
session.disconnect();
|
394
|
+
|
395
|
+
isEndall =true;
|
396
|
+
// killvc();
|
397
|
+
|
398
|
+
}
|
399
|
+
// public void killvc(){
|
400
|
+
// runOnUiThread(new Runnable() {
|
401
|
+
// @Override
|
402
|
+
// public void run() {
|
403
|
+
// Log.d("endVideoCall","PluginMethodendVideoCall");
|
404
|
+
// Log.d("endVideoCall",session.toString());
|
405
|
+
//
|
406
|
+
// }
|
407
|
+
// });
|
408
|
+
//
|
409
|
+
//
|
410
|
+
// }
|
319
411
|
private void startTimer() {
|
320
412
|
// startTime = System.currentTimeMillis();
|
321
413
|
Handler handler = new Handler();
|
@@ -390,10 +482,10 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
|
|
390
482
|
|
391
483
|
|
392
484
|
private void initializeSession(String apiKey, String sessionId, String token) {
|
485
|
+
Log.i(TAG, "initializeSession: " + "initializeSession");
|
393
486
|
Log.i(TAG, "apiKey: " + apiKey);
|
394
487
|
Log.i(TAG, "sessionId: " + sessionId);
|
395
488
|
Log.i(TAG, "token: " + token);
|
396
|
-
|
397
489
|
/*
|
398
490
|
The context used depends on the specific use case, but usually, it is desired for the session to
|
399
491
|
live outside of the Activity e.g: live between activities. For a production applications,
|
@@ -402,6 +494,8 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
|
|
402
494
|
session = new Session.Builder(this, apiKey, sessionId).build();
|
403
495
|
session.setSessionListener(sessionListener);
|
404
496
|
session.connect(token);
|
497
|
+
Log.d("initializeSession","session.toString()");
|
498
|
+
Log.d("initializeSession",session.toString());
|
405
499
|
}
|
406
500
|
|
407
501
|
// private void initRetrofit() {
|
@@ -421,14 +515,39 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
|
|
421
515
|
//// apiService = retrofit.create(APIService.class);
|
422
516
|
// }
|
423
517
|
|
518
|
+
private void showToast(String message) {
|
519
|
+
Toast.makeText(this, message, Toast.LENGTH_LONG).show();
|
520
|
+
}
|
424
521
|
private void finishWithMessage(String message) {
|
425
522
|
Log.e(TAG, message);
|
426
|
-
Toast.makeText(this, message, Toast.LENGTH_LONG).show();
|
523
|
+
// Toast.makeText(this, message, Toast.LENGTH_LONG).show();
|
427
524
|
session.disconnect();
|
428
525
|
Intent resultIntent = new Intent();
|
429
526
|
String resultcode = ISPROVIDER?"999":"888";
|
430
|
-
resultIntent.putExtra("result_key", resultcode);
|
527
|
+
resultIntent.putExtra("result_key", resultcode);
|
431
528
|
setResult(RESULT_OK, resultIntent);
|
432
529
|
this.finish();
|
433
530
|
}
|
531
|
+
private class DownloadImageFromInternet extends AsyncTask<String, Void, Bitmap> {
|
532
|
+
ImageView imageView;
|
533
|
+
public DownloadImageFromInternet(ImageView imageView) {
|
534
|
+
this.imageView=imageView;
|
535
|
+
Toast.makeText(getApplicationContext(), "Please wait, it may take a few minute...",Toast.LENGTH_SHORT).show();
|
536
|
+
}
|
537
|
+
protected Bitmap doInBackground(String... urls) {
|
538
|
+
String imageURL=urls[0];
|
539
|
+
Bitmap bimage=null;
|
540
|
+
try {
|
541
|
+
InputStream in=new java.net.URL(imageURL).openStream();
|
542
|
+
bimage= BitmapFactory.decodeStream(in);
|
543
|
+
} catch (Exception e) {
|
544
|
+
Log.e("Error Message", e.getMessage());
|
545
|
+
e.printStackTrace();
|
546
|
+
}
|
547
|
+
return bimage;
|
548
|
+
}
|
549
|
+
protected void onPostExecute(Bitmap result) {
|
550
|
+
imageView.setImageBitmap(result);
|
551
|
+
}
|
552
|
+
}
|
434
553
|
}
|
File without changes
|
@@ -9,6 +9,7 @@ import com.opentok.android.Subscriber;
|
|
9
9
|
import android.app.Activity;
|
10
10
|
import android.content.Intent;
|
11
11
|
import android.os.Handler;
|
12
|
+
import android.os.Looper;
|
12
13
|
import android.util.Log;
|
13
14
|
|
14
15
|
import com.getcapacitor.JSObject;
|
@@ -20,10 +21,33 @@ import com.getcapacitor.annotation.CapacitorPlugin;
|
|
20
21
|
|
21
22
|
@CapacitorPlugin(name = "vonage",requestCodes = {999})
|
22
23
|
public class vonagePlugin extends Plugin {
|
23
|
-
|
24
|
+
String Tag = "VONAGETAG";
|
25
|
+
Boolean isProvid=false;
|
24
26
|
private Session session;
|
25
27
|
|
26
28
|
private String TAG = "Capacitor_Vonage_plugin";
|
29
|
+
|
30
|
+
@PluginMethod()
|
31
|
+
public void endVideoCall(PluginCall call) {
|
32
|
+
showLog("endVideoCallPluginMethod");
|
33
|
+
|
34
|
+
|
35
|
+
|
36
|
+
Handler mainHandler = new Handler(Looper.getMainLooper());
|
37
|
+
Runnable myRunnable = new Runnable() {
|
38
|
+
@Override
|
39
|
+
public void run() {
|
40
|
+
try{
|
41
|
+
// VideoCallActivity videoCallActivity = new VideoCallActivity();
|
42
|
+
// videoCallActivity.;
|
43
|
+
}catch (Exception e){
|
44
|
+
showLog(e.toString());
|
45
|
+
}
|
46
|
+
}
|
47
|
+
};
|
48
|
+
mainHandler.post(myRunnable);
|
49
|
+
|
50
|
+
}
|
27
51
|
@PluginMethod()
|
28
52
|
public void openVideoCallWindow(PluginCall call) {
|
29
53
|
|
@@ -35,6 +59,7 @@ public class vonagePlugin extends Plugin {
|
|
35
59
|
final String PUBLISHERNAME = call.getString("publisherName");
|
36
60
|
final String SUBSCRIBERNAME = call.getString("subscriberName");
|
37
61
|
final Boolean ISPROVIDER = call.getBoolean("isProvider");
|
62
|
+
isProvid = ISPROVIDER;
|
38
63
|
// initializeSession(API_KEY, SESSION_ID, TOKEN);
|
39
64
|
Intent intent = new Intent(getContext(), VideoCallActivity.class);
|
40
65
|
intent.putExtra("apiKey",API_KEY);
|
@@ -42,20 +67,19 @@ public class vonagePlugin extends Plugin {
|
|
42
67
|
intent.putExtra("token",TOKEN);
|
43
68
|
intent.putExtra("subscriberName",SUBSCRIBERNAME);
|
44
69
|
intent.putExtra("publisherName",PUBLISHERNAME);
|
45
|
-
intent.putExtra("publisherName",PUBLISHERNAME);
|
46
70
|
intent.putExtra("isProvider",ISPROVIDER);
|
47
71
|
// intent.putExtra("callbackIdentifier", );
|
48
72
|
// notifyListeners("onDataReceived", );
|
49
73
|
// StartedCall();
|
50
74
|
Handler handler = new Handler();
|
51
|
-
int delayMillis =
|
75
|
+
int delayMillis = 2000;
|
52
76
|
|
53
77
|
handler.postDelayed(new Runnable() {
|
54
78
|
@Override
|
55
79
|
public void run() {
|
56
|
-
|
57
80
|
eventData.put("isProvider", ISPROVIDER);
|
58
81
|
notifyListeners("VideoCallStarted",eventData);
|
82
|
+
Log.d("VIDEOCALL","isProvider634");
|
59
83
|
}
|
60
84
|
}, delayMillis);
|
61
85
|
startActivityForResult(call,intent,999);
|
@@ -73,16 +97,25 @@ public class vonagePlugin extends Plugin {
|
|
73
97
|
Log.d(TAG, String.valueOf(resultCode));
|
74
98
|
Log.d(TAG, String.valueOf(requestCode));
|
75
99
|
Log.d(TAG, String.valueOf(data));
|
76
|
-
String result =
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
100
|
+
String result = "";
|
101
|
+
try{
|
102
|
+
result = data.getStringExtra("result_key");
|
103
|
+
showLog("result");
|
104
|
+
showLog(result);
|
105
|
+
}catch(Exception e){
|
106
|
+
showLog("ewererewrwerwe");
|
107
|
+
showLog(e.toString());
|
108
|
+
}
|
109
|
+
VideoCallActivity videoCallActivity = new VideoCallActivity();
|
110
|
+
if(!videoCallActivity.isEndall){
|
111
|
+
if (isProvid) {
|
112
|
+
eventData.put("isProvider", true);
|
113
|
+
notifyListeners("VideoCallEnded", eventData);
|
114
|
+
} else {
|
115
|
+
eventData.put("isProvider", false);
|
116
|
+
Log.d(TAG, "CODE 98 -----------");
|
117
|
+
notifyListeners("VideoCallEnded", eventData);
|
118
|
+
}
|
86
119
|
}
|
87
120
|
}
|
88
121
|
|
@@ -122,4 +155,7 @@ public class vonagePlugin extends Plugin {
|
|
122
155
|
// session.setSessionListener(sessionListener);
|
123
156
|
// session.connect(token);
|
124
157
|
// }
|
158
|
+
private void showLog(String log){
|
159
|
+
Log.d(Tag,log);
|
160
|
+
}
|
125
161
|
}
|
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
|
File without changes
|
@@ -30,21 +30,32 @@
|
|
30
30
|
app:layout_constraintEnd_toEndOf="parent"
|
31
31
|
app:layout_constraintStart_toStartOf="parent"
|
32
32
|
app:layout_constraintTop_toTopOf="parent">
|
33
|
+
<!-- android:background="#FF5733"-->
|
33
34
|
|
34
35
|
<FrameLayout
|
35
36
|
android:id="@+id/subscriber_container"
|
36
37
|
android:layout_width="fill_parent"
|
37
|
-
android:layout_height="match_parent"
|
38
|
+
android:layout_height="match_parent"
|
39
|
+
android:background="#9b9c98" >
|
40
|
+
|
41
|
+
<ImageView
|
42
|
+
android:id="@+id/image_view"
|
43
|
+
android:layout_width="150dp"
|
44
|
+
android:layout_height="150dp"
|
45
|
+
android:scaleType="centerCrop" />
|
46
|
+
</FrameLayout>
|
38
47
|
|
39
48
|
<TextView
|
40
|
-
android:id="@+id/
|
41
|
-
android:layout_width="
|
42
|
-
android:layout_height="
|
49
|
+
android:id="@+id/publisherName"
|
50
|
+
android:layout_width="150dp"
|
51
|
+
android:layout_height="wrap_content"
|
52
|
+
|
43
53
|
android:layout_gravity="bottom|start"
|
44
54
|
android:paddingLeft="10dp"
|
45
55
|
android:paddingBottom="120dp"
|
56
|
+
|
46
57
|
android:text="Publisher Name"
|
47
|
-
android:textColor="@android:color/
|
58
|
+
android:textColor="@android:color/white"
|
48
59
|
android:textSize="16sp"
|
49
60
|
android:visibility="visible" />
|
50
61
|
<TextView
|
@@ -56,7 +67,7 @@
|
|
56
67
|
android:paddingLeft="10dp"
|
57
68
|
android:text="00:00:00"
|
58
69
|
android:visibility="visible"
|
59
|
-
android:textColor="@android:color/
|
70
|
+
android:textColor="@android:color/white"
|
60
71
|
android:textSize="16sp" />
|
61
72
|
|
62
73
|
<FrameLayout
|
@@ -67,19 +78,39 @@
|
|
67
78
|
android:layout_marginEnd="16dp"
|
68
79
|
android:layout_marginRight="16dp"
|
69
80
|
android:layout_marginBottom="80dp"
|
70
|
-
android:background="#
|
81
|
+
android:background="#9b9c98"
|
82
|
+
android:layout_below="@id/subscriberName"
|
83
|
+
|
71
84
|
android:padding="2dp" >
|
72
|
-
|
73
|
-
android:id="@+id/publisherName"
|
74
|
-
android:layout_width="wrap_content"
|
75
|
-
android:layout_height="wrap_content"
|
76
|
-
android:layout_gravity="bottom|start"
|
77
|
-
android:textSize="12sp"
|
78
|
-
android:text="Subscriber Name"
|
79
|
-
android:paddingBottom="5dp"
|
80
|
-
android:visibility="visible"
|
81
|
-
android:textColor="@android:color/background_dark" />
|
85
|
+
|
82
86
|
</FrameLayout>
|
87
|
+
<TextView
|
88
|
+
android:id="@+id/subscriberName"
|
89
|
+
android:layout_width="100dp"
|
90
|
+
android:layout_height="wrap_content"
|
91
|
+
android:layout_gravity="bottom|end"
|
92
|
+
android:textSize="12sp"
|
93
|
+
android:text="Subscriber Name"
|
94
|
+
android:paddingBottom="25dp"
|
95
|
+
android:layout_marginRight="16dp"
|
96
|
+
android:layout_marginBottom="80dp"
|
97
|
+
android:textColor="@android:color/white" />
|
98
|
+
<androidx.cardview.widget.CardView
|
99
|
+
android:layout_width="155dp"
|
100
|
+
android:layout_height="155dp"
|
101
|
+
app:cardCornerRadius="250dp"
|
102
|
+
app:cardBackgroundColor="@android:color/white">
|
103
|
+
|
104
|
+
<androidx.cardview.widget.CardView
|
105
|
+
android:layout_width="150dp"
|
106
|
+
android:layout_height="150dp"
|
107
|
+
app:cardCornerRadius="250dp"
|
108
|
+
android:layout_gravity="center">
|
109
|
+
|
110
|
+
</androidx.cardview.widget.CardView>
|
111
|
+
|
112
|
+
</androidx.cardview.widget.CardView>
|
113
|
+
|
83
114
|
|
84
115
|
</FrameLayout>
|
85
116
|
|
@@ -92,7 +123,7 @@
|
|
92
123
|
|
93
124
|
<LinearLayout
|
94
125
|
android:layout_width="fill_parent"
|
95
|
-
android:layout_height="
|
126
|
+
android:layout_height="53dp"
|
96
127
|
android:layout_alignParentBottom="false"
|
97
128
|
android:gravity="clip_horizontal"
|
98
129
|
android:orientation="horizontal"
|
package/android/src/main/res.zip
CHANGED
File without changes
|
package/dist/docs.json
CHANGED
@@ -39,6 +39,16 @@
|
|
39
39
|
],
|
40
40
|
"slug": "openvideocallwindow"
|
41
41
|
},
|
42
|
+
{
|
43
|
+
"name": "endVideoCall",
|
44
|
+
"signature": "() => Promise<{ value: string; }>",
|
45
|
+
"parameters": [],
|
46
|
+
"returns": "Promise<{ value: string; }>",
|
47
|
+
"tags": [],
|
48
|
+
"docs": "",
|
49
|
+
"complexTypes": [],
|
50
|
+
"slug": "endvideocall"
|
51
|
+
},
|
42
52
|
{
|
43
53
|
"name": "addListener",
|
44
54
|
"signature": "(...args: [eventName: \"VideoCallEnded\", listenerFunc: (info: any) => void] | [eventName: \"VideoCallStarted\", listenerFunc: (info: any) => void]) => Promise<PluginListenerHandle> & PluginListenerHandle",
|
@@ -8,5 +8,8 @@ export interface vonagePlugin {
|
|
8
8
|
openVideoCallWindow(options: Object): Promise<{
|
9
9
|
value: any;
|
10
10
|
}>;
|
11
|
+
endVideoCall(): Promise<{
|
12
|
+
value: string;
|
13
|
+
}>;
|
11
14
|
addListener(...args: [eventName: 'VideoCallEnded', listenerFunc: (info: any) => void] | [eventName: 'VideoCallStarted', listenerFunc: (info: any) => void]): Promise<PluginListenerHandle> & PluginListenerHandle;
|
12
15
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["import { PluginListenerHandle } from \"@capacitor/core\";\n\nexport interface vonagePlugin {\n echo(options: { value: string }): Promise<{ value: string }>;\n openVideoCallWindow(options: Object): Promise<{ value: any }>;\n addListener(...args: [eventName: 'VideoCallEnded', listenerFunc: (info: any) => void] | [eventName: 'VideoCallStarted', listenerFunc: (info: any) => void]): Promise<PluginListenerHandle> & PluginListenerHandle;\n\n}\n"]}
|
1
|
+
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["import { PluginListenerHandle } from \"@capacitor/core\";\n\nexport interface vonagePlugin {\n echo(options: { value: string }): Promise<{ value: string }>;\n openVideoCallWindow(options: Object): Promise<{ value: any }>;\n endVideoCall(): Promise<{ value: string }>;\n addListener(...args: [eventName: 'VideoCallEnded', listenerFunc: (info: any) => void] | [eventName: 'VideoCallStarted', listenerFunc: (info: any) => void]): Promise<PluginListenerHandle> & PluginListenerHandle;\n\n}\n"]}
|
package/dist/esm/web.d.ts
CHANGED
@@ -1,6 +1,9 @@
|
|
1
1
|
import { WebPlugin } from '@capacitor/core';
|
2
2
|
import type { vonagePlugin } from './definitions';
|
3
3
|
export declare class vonageWeb extends WebPlugin implements vonagePlugin {
|
4
|
+
endVideoCall(): Promise<{
|
5
|
+
value: string;
|
6
|
+
}>;
|
4
7
|
echo(options: {
|
5
8
|
value: string;
|
6
9
|
}): Promise<{
|
package/dist/esm/web.js
CHANGED
package/dist/esm/web.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAI5C,MAAM,OAAO,SAAU,SAAQ,SAAS;IACtC,KAAK,CAAC,IAAI,CAAC,OAA0B;QACnC,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAC7B,OAAO,OAAO,CAAC;IACjB,CAAC;IACD,KAAK,CAAC,mBAAmB,CAAC,OAAe;QACvC,IAAI,UAAc,CAAC;QACnB,OAAO,CAAC,GAAG,CAAC,qBAAqB,EAAE,OAAO,CAAC,CAAC;QAC5C,OAAO,UAAU,CAAC;IACpB,CAAC;CACF","sourcesContent":["import { WebPlugin } from '@capacitor/core';\n\nimport type { vonagePlugin } from './definitions';\n\nexport class vonageWeb extends WebPlugin implements vonagePlugin {\n async echo(options: { value: string }): Promise<{ value: string }> {\n console.log('ECHO', options);\n return options;\n }\n async openVideoCallWindow(options: Object): Promise<{ value: any }>{\n let dummyValue:any;\n console.log('openVideoCallWindow', options);\n return dummyValue;\n }\n}\n"]}
|
1
|
+
{"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAI5C,MAAM,OAAO,SAAU,SAAQ,SAAS;IACtC,YAAY;QACV,IAAI,UAAc,CAAC;QACnB,OAAO,UAAU,CAAC;IACpB,CAAC;IACD,KAAK,CAAC,IAAI,CAAC,OAA0B;QACnC,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAC7B,OAAO,OAAO,CAAC;IACjB,CAAC;IACD,KAAK,CAAC,mBAAmB,CAAC,OAAe;QACvC,IAAI,UAAc,CAAC;QACnB,OAAO,CAAC,GAAG,CAAC,qBAAqB,EAAE,OAAO,CAAC,CAAC;QAC5C,OAAO,UAAU,CAAC;IACpB,CAAC;CACF","sourcesContent":["import { WebPlugin } from '@capacitor/core';\n\nimport type { vonagePlugin } from './definitions';\n\nexport class vonageWeb extends WebPlugin implements vonagePlugin {\n endVideoCall(): Promise<{ value: string; }> {\n let dummyValue:any;\n return dummyValue;\n }\n async echo(options: { value: string }): Promise<{ value: string }> {\n console.log('ECHO', options);\n return options;\n }\n async openVideoCallWindow(options: Object): Promise<{ value: any }>{\n let dummyValue:any;\n console.log('openVideoCallWindow', options);\n return dummyValue;\n }\n}\n"]}
|
package/dist/plugin.cjs.js
CHANGED
package/dist/plugin.cjs.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"plugin.cjs.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst vonage = registerPlugin('vonage', {\n web: () => import('./web').then(m => new m.vonageWeb()),\n});\nexport * from './definitions';\nexport { vonage };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class vonageWeb extends WebPlugin {\n async echo(options) {\n console.log('ECHO', options);\n return options;\n }\n async openVideoCallWindow(options) {\n let dummyValue;\n console.log('openVideoCallWindow', options);\n return dummyValue;\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;;;;AACK,MAAC,MAAM,GAAGA,mBAAc,CAAC,QAAQ,EAAE;AACxC,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,SAAS,EAAE,CAAC;AAC3D,CAAC;;ACFM,MAAM,SAAS,SAASC,cAAS,CAAC;AACzC,IAAI,MAAM,IAAI,CAAC,OAAO,EAAE;AACxB,QAAQ,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AACrC,QAAQ,OAAO,OAAO,CAAC;AACvB,KAAK;AACL,IAAI,MAAM,mBAAmB,CAAC,OAAO,EAAE;AACvC,QAAQ,IAAI,UAAU,CAAC;AACvB,QAAQ,OAAO,CAAC,GAAG,CAAC,qBAAqB,EAAE,OAAO,CAAC,CAAC;AACpD,QAAQ,OAAO,UAAU,CAAC;AAC1B,KAAK;AACL;;;;;;;;;"}
|
1
|
+
{"version":3,"file":"plugin.cjs.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst vonage = registerPlugin('vonage', {\n web: () => import('./web').then(m => new m.vonageWeb()),\n});\nexport * from './definitions';\nexport { vonage };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class vonageWeb extends WebPlugin {\n endVideoCall() {\n let dummyValue;\n return dummyValue;\n }\n async echo(options) {\n console.log('ECHO', options);\n return options;\n }\n async openVideoCallWindow(options) {\n let dummyValue;\n console.log('openVideoCallWindow', options);\n return dummyValue;\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;;;;AACK,MAAC,MAAM,GAAGA,mBAAc,CAAC,QAAQ,EAAE;AACxC,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,SAAS,EAAE,CAAC;AAC3D,CAAC;;ACFM,MAAM,SAAS,SAASC,cAAS,CAAC;AACzC,IAAI,YAAY,GAAG;AACnB,QAAQ,IAAI,UAAU,CAAC;AACvB,QAAQ,OAAO,UAAU,CAAC;AAC1B,KAAK;AACL,IAAI,MAAM,IAAI,CAAC,OAAO,EAAE;AACxB,QAAQ,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AACrC,QAAQ,OAAO,OAAO,CAAC;AACvB,KAAK;AACL,IAAI,MAAM,mBAAmB,CAAC,OAAO,EAAE;AACvC,QAAQ,IAAI,UAAU,CAAC;AACvB,QAAQ,OAAO,CAAC,GAAG,CAAC,qBAAqB,EAAE,OAAO,CAAC,CAAC;AACpD,QAAQ,OAAO,UAAU,CAAC;AAC1B,KAAK;AACL;;;;;;;;;"}
|
package/dist/plugin.js
CHANGED
package/dist/plugin.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"plugin.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst vonage = registerPlugin('vonage', {\n web: () => import('./web').then(m => new m.vonageWeb()),\n});\nexport * from './definitions';\nexport { vonage };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class vonageWeb extends WebPlugin {\n async echo(options) {\n console.log('ECHO', options);\n return options;\n }\n async openVideoCallWindow(options) {\n let dummyValue;\n console.log('openVideoCallWindow', options);\n return dummyValue;\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;AACK,UAAC,MAAM,GAAGA,mBAAc,CAAC,QAAQ,EAAE;IACxC,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,SAAS,EAAE,CAAC;IAC3D,CAAC;;ICFM,MAAM,SAAS,SAASC,cAAS,CAAC;IACzC,IAAI,MAAM,IAAI,CAAC,OAAO,EAAE;IACxB,QAAQ,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACrC,QAAQ,OAAO,OAAO,CAAC;IACvB,KAAK;IACL,IAAI,MAAM,mBAAmB,CAAC,OAAO,EAAE;IACvC,QAAQ,IAAI,UAAU,CAAC;IACvB,QAAQ,OAAO,CAAC,GAAG,CAAC,qBAAqB,EAAE,OAAO,CAAC,CAAC;IACpD,QAAQ,OAAO,UAAU,CAAC;IAC1B,KAAK;IACL;;;;;;;;;;;;;;;;;"}
|
1
|
+
{"version":3,"file":"plugin.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst vonage = registerPlugin('vonage', {\n web: () => import('./web').then(m => new m.vonageWeb()),\n});\nexport * from './definitions';\nexport { vonage };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class vonageWeb extends WebPlugin {\n endVideoCall() {\n let dummyValue;\n return dummyValue;\n }\n async echo(options) {\n console.log('ECHO', options);\n return options;\n }\n async openVideoCallWindow(options) {\n let dummyValue;\n console.log('openVideoCallWindow', options);\n return dummyValue;\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;AACK,UAAC,MAAM,GAAGA,mBAAc,CAAC,QAAQ,EAAE;IACxC,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,SAAS,EAAE,CAAC;IAC3D,CAAC;;ICFM,MAAM,SAAS,SAASC,cAAS,CAAC;IACzC,IAAI,YAAY,GAAG;IACnB,QAAQ,IAAI,UAAU,CAAC;IACvB,QAAQ,OAAO,UAAU,CAAC;IAC1B,KAAK;IACL,IAAI,MAAM,IAAI,CAAC,OAAO,EAAE;IACxB,QAAQ,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACrC,QAAQ,OAAO,OAAO,CAAC;IACvB,KAAK;IACL,IAAI,MAAM,mBAAmB,CAAC,OAAO,EAAE;IACvC,QAAQ,IAAI,UAAU,CAAC;IACvB,QAAQ,OAAO,CAAC,GAAG,CAAC,qBAAqB,EAAE,OAAO,CAAC,CAAC;IACpD,QAAQ,OAAO,UAAU,CAAC;IAC1B,KAAK;IACL;;;;;;;;;;;;;;;;;"}
|
@@ -9,6 +9,7 @@ import UIKit
|
|
9
9
|
import OpenTok
|
10
10
|
|
11
11
|
class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDelegate,OTSubscriberDelegate {
|
12
|
+
var isCallEnded = false
|
12
13
|
var kApiKey = ""
|
13
14
|
var kSessionId = ""
|
14
15
|
var kToken = ""
|
@@ -41,6 +42,7 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
|
|
41
42
|
var counter = 0
|
42
43
|
var timer = Timer()
|
43
44
|
override func viewDidLoad() {
|
45
|
+
|
44
46
|
super.viewDidLoad()
|
45
47
|
self.navigationController?.navigationBar.isHidden = true
|
46
48
|
self.viewSetupMethod()
|
@@ -85,10 +87,26 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
|
|
85
87
|
}
|
86
88
|
override func viewDidAppear(_ animated: Bool) {
|
87
89
|
super.viewDidAppear(animated)
|
90
|
+
NotificationCenter.default.addObserver(self,selector:#selector(endVideoCall(_:)),name: NSNotification.Name ("EndVideoCall"),object: nil)
|
88
91
|
// DispatchQueue.main.asyncAfter(deadline: .now() + 1.0, execute: {
|
89
92
|
//
|
90
93
|
// self.connectToAnOpenTokSession()
|
91
94
|
// })
|
95
|
+
// if(isVideoMute){
|
96
|
+
// subscriberImg.isHidden = true
|
97
|
+
// }else{
|
98
|
+
// subscriberImg.isHidden = false
|
99
|
+
// }
|
100
|
+
// turnOnAndOffVideo()
|
101
|
+
}
|
102
|
+
override func viewDidDisappear(_ animated: Bool) {
|
103
|
+
super.viewDidDisappear(animated)
|
104
|
+
NotificationCenter.default.removeObserver(self, name: NSNotification.Name("EndVideoCall"), object: nil)
|
105
|
+
}
|
106
|
+
@objc func endVideoCall(_ notification: Notification){
|
107
|
+
print("end video call called")
|
108
|
+
endVonageCall()
|
109
|
+
NotificationCenter.default.removeObserver(self, name: NSNotification.Name("EndVideoCall"), object: nil)
|
92
110
|
}
|
93
111
|
func startTimer(){
|
94
112
|
timer.invalidate()
|
@@ -208,6 +226,13 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
|
|
208
226
|
audioBtn.addTarget(self, action:#selector(self.audioBtnbuttonClicked), for: .touchUpInside)
|
209
227
|
bottomView.addSubview(audioBtn)
|
210
228
|
|
229
|
+
}
|
230
|
+
deinit{
|
231
|
+
if(!isCallEnded){
|
232
|
+
let userInfo = ["userInfo": ["isProvider": self.isProvider]]
|
233
|
+
NotificationCenter.default.post(name: NSNotification.Name(NotificationNames.videoEnded),object: nil,userInfo: userInfo)
|
234
|
+
}
|
235
|
+
|
211
236
|
}
|
212
237
|
|
213
238
|
@objc func callBtnbuttonClicked() {
|
@@ -233,6 +258,9 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
|
|
233
258
|
}
|
234
259
|
|
235
260
|
@objc func videoBtnbuttonClicked() {
|
261
|
+
turnOnAndOffVideo()
|
262
|
+
}
|
263
|
+
func turnOnAndOffVideo(){
|
236
264
|
if (self.isVideoMute) {
|
237
265
|
self.publisher?.publishVideo = true
|
238
266
|
self.videoBtn.setImage(UIImage(named : "cameraOnWhite"), for: .normal)
|
@@ -275,6 +303,7 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
|
|
275
303
|
let settings = OTPublisherSettings()
|
276
304
|
settings.name = publisherName
|
277
305
|
guard let publisher = OTPublisher(delegate: self, settings: settings) else {
|
306
|
+
print("publisher create error")
|
278
307
|
return
|
279
308
|
}
|
280
309
|
self.publisher = publisher
|
@@ -286,6 +315,7 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
|
|
286
315
|
}
|
287
316
|
|
288
317
|
guard let publisherView = publisher.view else {
|
318
|
+
print("publisher view not created")
|
289
319
|
return
|
290
320
|
}
|
291
321
|
|
@@ -300,6 +330,10 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
|
|
300
330
|
func sessionDidDisconnect(_ session: OTSession) {
|
301
331
|
print("The client disconnected from the OpenTok session.")
|
302
332
|
// self.session?.disconnect(nil)
|
333
|
+
if(!isCallEnded){
|
334
|
+
let userInfo = ["userInfo": ["isProvider": self.isProvider]]
|
335
|
+
NotificationCenter.default.post(name: NSNotification.Name(NotificationNames.videoEnded),object: nil,userInfo: userInfo)
|
336
|
+
}
|
303
337
|
self.dismiss(animated: true, completion: nil)
|
304
338
|
}
|
305
339
|
|
@@ -326,6 +360,9 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
|
|
326
360
|
}
|
327
361
|
|
328
362
|
subscriberView.frame = UIScreen.main.bounds
|
363
|
+
if(stream.videoType == .screen){
|
364
|
+
subscriberView.accessibilityValue = "from screen"
|
365
|
+
}
|
329
366
|
remoteView.addSubview(subscriberView)
|
330
367
|
}
|
331
368
|
|
@@ -337,16 +374,26 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
|
|
337
374
|
// self.session?.disconnect(nil)
|
338
375
|
// self.dismiss(animated: true, completion: nil)
|
339
376
|
// }
|
340
|
-
if let subStream = subscriber?.stream, subStream.streamId == stream.streamId,!isProvider {
|
377
|
+
if let subStream = subscriber?.stream, subStream.streamId == stream.streamId,!isProvider, stream.videoType != .screen {
|
341
378
|
// cleanupSubscriber()
|
342
379
|
let userInfo = ["userInfo": ["isProvider": isProvider]]
|
343
380
|
NotificationCenter.default.post(name: NSNotification.Name(NotificationNames.videoEnded),object: nil,userInfo: userInfo)
|
344
381
|
self.session?.disconnect(nil)
|
345
382
|
self.dismiss(animated: true, completion: nil)
|
346
383
|
}
|
347
|
-
|
348
|
-
|
349
|
-
|
384
|
+
if(stream.videoType != .screen){
|
385
|
+
subscriberImg.isHidden = false
|
386
|
+
showToast(message: "\(subscriberName) is left the call")
|
387
|
+
cleanupSubscriber()
|
388
|
+
}
|
389
|
+
if(stream.videoType == .screen){
|
390
|
+
for subview in remoteView.subviews{
|
391
|
+
if(subview.accessibilityValue == "from screen"){
|
392
|
+
subview.removeFromSuperview()
|
393
|
+
}
|
394
|
+
}
|
395
|
+
}
|
396
|
+
|
350
397
|
|
351
398
|
}
|
352
399
|
|
@@ -368,7 +415,10 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
|
|
368
415
|
public func subscriberDidConnect(toStream subscriber: OTSubscriberKit) {
|
369
416
|
print("The subscriber did connect to the stream.")
|
370
417
|
subscriberImg.isHidden = true
|
371
|
-
|
418
|
+
if(subscriber.stream?.videoType != .screen){
|
419
|
+
showToast(message: "\(subscriberName) is joined the call")
|
420
|
+
}
|
421
|
+
|
372
422
|
}
|
373
423
|
|
374
424
|
public func subscriber(_ subscriber: OTSubscriberKit, didFailWithError error: OTError) {
|
@@ -391,14 +441,21 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
|
|
391
441
|
}
|
392
442
|
|
393
443
|
@IBAction func endCallAction(_ sender: Any) {
|
394
|
-
|
395
|
-
let userInfo = ["userInfo": ["isProvider": isProvider]]
|
444
|
+
isCallEnded = true
|
445
|
+
let userInfo = ["userInfo": ["isProvider": self.isProvider]]
|
396
446
|
NotificationCenter.default.post(name: NSNotification.Name(NotificationNames.videoEnded),object: nil,userInfo: userInfo)
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
447
|
+
endVonageCall()
|
448
|
+
}
|
449
|
+
fileprivate func endVonageCall(){
|
450
|
+
isCallEnded = true
|
451
|
+
DispatchQueue.main.async {
|
452
|
+
|
453
|
+
self.cleanupSubscriber()
|
454
|
+
self.cleanupPublisher()
|
455
|
+
self.session?.disconnect(nil)
|
456
|
+
self.stopTimer()
|
457
|
+
// self.dismiss(animated: true, completion: nil)
|
458
|
+
}
|
402
459
|
}
|
403
460
|
fileprivate func cleanupSubscriber() {
|
404
461
|
subscriber?.view?.removeFromSuperview()
|
@@ -46,6 +46,10 @@ public class vonagePlugin: CAPPlugin {
|
|
46
46
|
|
47
47
|
call.resolve(["value": "Video call initiated"])
|
48
48
|
}
|
49
|
+
@objc func endVideoCall(_ call: CAPPluginCall) {
|
50
|
+
NotificationCenter.default.post(name: NSNotification.Name("EndVideoCall"),object: nil,userInfo: nil)
|
51
|
+
call.resolve(["value": "Video call ended."])
|
52
|
+
}
|
49
53
|
@objc func videoEnded(_ notification: Notification){
|
50
54
|
self.notifyListeners(NotificationNames.videoEnded, data: notification.userInfo?["userInfo"] as? [String: Any] ?? [:])
|
51
55
|
NotificationCenter.default.removeObserver(self, name: NSNotification.Name(NotificationNames.videoEnded), object: nil)
|