capacitor-plugin-vonage 0.0.3 → 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/android/src/main/AndroidManifest.xml +2 -1
- package/android/src/main/java/com/managemyhealth/plugin/vonage/VideoCallActivity.java +119 -34
- package/android/src/main/java/com/managemyhealth/plugin/vonage/vonagePlugin.java +12 -10
- package/android/src/main/res/layout/video_call_layout.xml +45 -16
- package/ios/Plugin/VideoChatViewController.swift +36 -5
- package/package.json +1 -1
@@ -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,8 +51,10 @@ 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;
|
@@ -80,12 +86,12 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
|
|
80
86
|
public void onError(PublisherKit publisherKit, OpentokError opentokError) {
|
81
87
|
finishWithMessage("PublisherKit onError: " + opentokError.getMessage());
|
82
88
|
}
|
89
|
+
|
83
90
|
};
|
84
91
|
|
85
92
|
private final Session.SessionListener sessionListener = new Session.SessionListener() {
|
86
93
|
@Override
|
87
94
|
public void onConnected(Session session) {
|
88
|
-
|
89
95
|
Log.d(TAG, "onConnected: Connected to session: " + session.getSessionId());
|
90
96
|
// JSObject eventData = new JSObject();
|
91
97
|
// eventData.put("key", "value");
|
@@ -139,12 +145,14 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
|
|
139
145
|
|
140
146
|
@Override
|
141
147
|
public void onStreamReceived(Session session, Stream stream) {
|
148
|
+
|
142
149
|
Log.d(TAG, "onStreamReceived: New Stream Received " + stream.getStreamId() + " in session: " + session.getSessionId());
|
143
150
|
|
144
151
|
if (subscriber == null) {
|
145
152
|
subscriber = new Subscriber.Builder(VideoCallActivity.this, stream).build();
|
146
153
|
subscriber.getRenderer().setStyle(BaseVideoRenderer.STYLE_VIDEO_SCALE, BaseVideoRenderer.STYLE_VIDEO_FILL);
|
147
154
|
subscriber.setSubscriberListener(subscriberListener);
|
155
|
+
subscriber.setVideoListener(videoListener);
|
148
156
|
session.subscribe(subscriber);
|
149
157
|
try {
|
150
158
|
subscriberViewContainer.addView(subscriber.getView());
|
@@ -152,6 +160,8 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
|
|
152
160
|
Log.d("subscriberViewContainer", e.toString());
|
153
161
|
|
154
162
|
}
|
163
|
+
showToast(SUBSCRIBERNAME + "joined the call");
|
164
|
+
|
155
165
|
}
|
156
166
|
}
|
157
167
|
|
@@ -175,17 +185,51 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
|
|
175
185
|
if (subscriber != null) {
|
176
186
|
subscriber = null;
|
177
187
|
subscriberViewContainer.removeAllViews();
|
188
|
+
showToast(SUBSCRIBERNAME + " left the call");
|
189
|
+
|
178
190
|
}
|
179
191
|
}
|
180
192
|
}
|
181
193
|
|
194
|
+
|
182
195
|
@Override
|
183
196
|
public void onError(Session session, OpentokError opentokError) {
|
184
197
|
finishWithMessage("Session error: " + opentokError.getMessage());
|
185
198
|
}
|
186
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
|
+
};
|
187
230
|
|
188
231
|
SubscriberKit.SubscriberListener subscriberListener = new SubscriberKit.SubscriberListener() {
|
232
|
+
|
189
233
|
@Override
|
190
234
|
public void onConnected(SubscriberKit subscriberKit) {
|
191
235
|
Log.d(TAG, "onConnected: Subscriber connected. Stream: " + subscriberKit.getStream().getStreamId());
|
@@ -194,10 +238,14 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
|
|
194
238
|
@Override
|
195
239
|
public void onDisconnected(SubscriberKit subscriberKit) {
|
196
240
|
Log.d(TAG, "onDisconnected: Subscriber disconnected. Stream: " + subscriberKit.getStream().getStreamId());
|
241
|
+
|
197
242
|
}
|
198
243
|
|
244
|
+
|
245
|
+
|
199
246
|
@Override
|
200
247
|
public void onError(SubscriberKit subscriberKit, OpentokError opentokError) {
|
248
|
+
showToast(SUBSCRIBERNAME + " failed to connect to the call");
|
201
249
|
finishWithMessage("SubscriberKit onError: " + opentokError.getMessage());
|
202
250
|
}
|
203
251
|
};
|
@@ -219,6 +267,7 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
|
|
219
267
|
session.disconnect();
|
220
268
|
}
|
221
269
|
|
270
|
+
@SuppressLint("MissingInflatedId")
|
222
271
|
@Override
|
223
272
|
protected void onCreate(Bundle savedInstanceState) {
|
224
273
|
|
@@ -226,6 +275,8 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
|
|
226
275
|
|
227
276
|
super.onCreate(savedInstanceState);
|
228
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
|
+
|
229
280
|
getSupportActionBar().hide();
|
230
281
|
ActionBar actionBar = getActionBar();
|
231
282
|
if (actionBar != null) {
|
@@ -237,15 +288,15 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
|
|
237
288
|
String TOKEN = intent.getStringExtra("token");
|
238
289
|
String SESSION_ID = intent.getStringExtra("sessionId");
|
239
290
|
String API_KEY = intent.getStringExtra("apiKey");
|
240
|
-
|
241
|
-
|
291
|
+
SUBSCRIBERNAME = intent.getStringExtra("subscriberName");
|
292
|
+
PUBLISHERNAME = intent.getStringExtra("publisherName");
|
242
293
|
ISPROVIDER = intent.getBooleanExtra("isProvider",false);
|
243
294
|
publisherViewContainer = findViewById(R.id.publisher_container);
|
244
295
|
subscriberViewContainer = findViewById(R.id.subscriber_container);
|
245
296
|
TextView publisherNameTextView = findViewById(R.id.publisherName);
|
246
297
|
TextView subscriberNameTextView = findViewById(R.id.subscriberName);
|
247
|
-
publisherNameTextView.setText(
|
248
|
-
subscriberNameTextView.setText(
|
298
|
+
publisherNameTextView.setText(SUBSCRIBERNAME);
|
299
|
+
subscriberNameTextView.setText(PUBLISHERNAME);
|
249
300
|
timerTextView = findViewById(R.id.timerTextView);
|
250
301
|
startTime = System.currentTimeMillis();
|
251
302
|
isTimeron =true;
|
@@ -270,30 +321,34 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
|
|
270
321
|
}
|
271
322
|
});
|
272
323
|
|
273
|
-
imageViewMute.setOnClickListener(new View.OnClickListener() {
|
324
|
+
imageViewMute.setOnClickListener(new View.OnClickListener() {//mute and unmute audio
|
274
325
|
@Override
|
275
326
|
public void onClick(View v) {
|
276
327
|
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
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;
|
283
337
|
}
|
284
|
-
isMuted = !isMuted;
|
285
338
|
|
286
339
|
}
|
287
340
|
});
|
288
|
-
imageViewCamOff.setOnClickListener(new View.OnClickListener() {
|
341
|
+
imageViewCamOff.setOnClickListener(new View.OnClickListener() {//off & on camera
|
289
342
|
@Override
|
290
343
|
public void onClick(View v) {
|
344
|
+
if(publisher!=null) {
|
291
345
|
|
292
346
|
if (!isCamOff) {
|
293
347
|
publisher.setPublishVideo(false);
|
294
348
|
imageViewCamOff.setImageResource(R.drawable.cameraoff);
|
295
349
|
imageViewCamSwitch.setVisibility(View.GONE);
|
296
350
|
|
351
|
+
|
297
352
|
} else {
|
298
353
|
publisher.setPublishVideo(true);
|
299
354
|
imageViewCamOff.setImageResource(R.drawable.cameraonwhite);
|
@@ -303,14 +358,14 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
|
|
303
358
|
isCamOff = !isCamOff;
|
304
359
|
|
305
360
|
}
|
361
|
+
}
|
306
362
|
});
|
307
363
|
imageViewCamSwitch.setOnClickListener(new View.OnClickListener() {
|
308
364
|
@Override
|
309
365
|
public void onClick(View v) {
|
310
|
-
publisher
|
311
|
-
|
312
|
-
|
313
|
-
|
366
|
+
if(publisher!=null) {
|
367
|
+
publisher.cycleCamera();//flip camera
|
368
|
+
}
|
314
369
|
}
|
315
370
|
});
|
316
371
|
|
@@ -335,21 +390,24 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
|
|
335
390
|
}
|
336
391
|
}
|
337
392
|
public void endCall() {
|
338
|
-
|
339
|
-
killvc();
|
340
|
-
|
341
|
-
}
|
342
|
-
public void killvc(){
|
343
|
-
runOnUiThread(new Runnable() {
|
344
|
-
@Override
|
345
|
-
public void run() {
|
346
|
-
Log.d("endVideoCall","PluginMethodendVideoCall");
|
347
|
-
// Update UI components or perform UI-related operations here
|
348
|
-
}
|
349
|
-
});
|
393
|
+
session.disconnect();
|
350
394
|
|
395
|
+
isEndall =true;
|
396
|
+
// killvc();
|
351
397
|
|
352
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
|
+
// }
|
353
411
|
private void startTimer() {
|
354
412
|
// startTime = System.currentTimeMillis();
|
355
413
|
Handler handler = new Handler();
|
@@ -424,10 +482,10 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
|
|
424
482
|
|
425
483
|
|
426
484
|
private void initializeSession(String apiKey, String sessionId, String token) {
|
485
|
+
Log.i(TAG, "initializeSession: " + "initializeSession");
|
427
486
|
Log.i(TAG, "apiKey: " + apiKey);
|
428
487
|
Log.i(TAG, "sessionId: " + sessionId);
|
429
488
|
Log.i(TAG, "token: " + token);
|
430
|
-
|
431
489
|
/*
|
432
490
|
The context used depends on the specific use case, but usually, it is desired for the session to
|
433
491
|
live outside of the Activity e.g: live between activities. For a production applications,
|
@@ -436,6 +494,8 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
|
|
436
494
|
session = new Session.Builder(this, apiKey, sessionId).build();
|
437
495
|
session.setSessionListener(sessionListener);
|
438
496
|
session.connect(token);
|
497
|
+
Log.d("initializeSession","session.toString()");
|
498
|
+
Log.d("initializeSession",session.toString());
|
439
499
|
}
|
440
500
|
|
441
501
|
// private void initRetrofit() {
|
@@ -455,9 +515,12 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
|
|
455
515
|
//// apiService = retrofit.create(APIService.class);
|
456
516
|
// }
|
457
517
|
|
518
|
+
private void showToast(String message) {
|
519
|
+
Toast.makeText(this, message, Toast.LENGTH_LONG).show();
|
520
|
+
}
|
458
521
|
private void finishWithMessage(String message) {
|
459
522
|
Log.e(TAG, message);
|
460
|
-
Toast.makeText(this, message, Toast.LENGTH_LONG).show();
|
523
|
+
// Toast.makeText(this, message, Toast.LENGTH_LONG).show();
|
461
524
|
session.disconnect();
|
462
525
|
Intent resultIntent = new Intent();
|
463
526
|
String resultcode = ISPROVIDER?"999":"888";
|
@@ -465,4 +528,26 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi
|
|
465
528
|
setResult(RESULT_OK, resultIntent);
|
466
529
|
this.finish();
|
467
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
|
+
}
|
468
553
|
}
|
@@ -38,8 +38,8 @@ public class vonagePlugin extends Plugin {
|
|
38
38
|
@Override
|
39
39
|
public void run() {
|
40
40
|
try{
|
41
|
-
VideoCallActivity videoCallActivity = new VideoCallActivity();
|
42
|
-
videoCallActivity
|
41
|
+
// VideoCallActivity videoCallActivity = new VideoCallActivity();
|
42
|
+
// videoCallActivity.;
|
43
43
|
}catch (Exception e){
|
44
44
|
showLog(e.toString());
|
45
45
|
}
|
@@ -67,7 +67,6 @@ public class vonagePlugin extends Plugin {
|
|
67
67
|
intent.putExtra("token",TOKEN);
|
68
68
|
intent.putExtra("subscriberName",SUBSCRIBERNAME);
|
69
69
|
intent.putExtra("publisherName",PUBLISHERNAME);
|
70
|
-
intent.putExtra("publisherName",PUBLISHERNAME);
|
71
70
|
intent.putExtra("isProvider",ISPROVIDER);
|
72
71
|
// intent.putExtra("callbackIdentifier", );
|
73
72
|
// notifyListeners("onDataReceived", );
|
@@ -107,13 +106,16 @@ public class vonagePlugin extends Plugin {
|
|
107
106
|
showLog("ewererewrwerwe");
|
108
107
|
showLog(e.toString());
|
109
108
|
}
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
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
|
+
}
|
117
119
|
}
|
118
120
|
}
|
119
121
|
|
@@ -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
49
|
android:id="@+id/publisherName"
|
41
|
-
android:layout_width="
|
42
|
-
android:layout_height="
|
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,21 +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"
|
71
82
|
android:layout_below="@id/subscriberName"
|
72
83
|
|
73
84
|
android:padding="2dp" >
|
74
85
|
|
75
|
-
<TextView
|
76
|
-
android:id="@+id/subscriberName"
|
77
|
-
android:layout_width="wrap_content"
|
78
|
-
android:layout_height="wrap_content"
|
79
|
-
android:layout_gravity="bottom|start"
|
80
|
-
android:textSize="12sp"
|
81
|
-
android:text="Subscriber Name"
|
82
|
-
android:paddingBottom="5dp"
|
83
|
-
android:textColor="@android:color/background_dark" />
|
84
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
|
+
|
85
114
|
|
86
115
|
</FrameLayout>
|
87
116
|
|
@@ -94,7 +123,7 @@
|
|
94
123
|
|
95
124
|
<LinearLayout
|
96
125
|
android:layout_width="fill_parent"
|
97
|
-
android:layout_height="
|
126
|
+
android:layout_height="53dp"
|
98
127
|
android:layout_alignParentBottom="false"
|
99
128
|
android:gravity="clip_horizontal"
|
100
129
|
android:orientation="horizontal"
|
@@ -92,6 +92,12 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
|
|
92
92
|
//
|
93
93
|
// self.connectToAnOpenTokSession()
|
94
94
|
// })
|
95
|
+
// if(isVideoMute){
|
96
|
+
// subscriberImg.isHidden = true
|
97
|
+
// }else{
|
98
|
+
// subscriberImg.isHidden = false
|
99
|
+
// }
|
100
|
+
// turnOnAndOffVideo()
|
95
101
|
}
|
96
102
|
override func viewDidDisappear(_ animated: Bool) {
|
97
103
|
super.viewDidDisappear(animated)
|
@@ -252,6 +258,9 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
|
|
252
258
|
}
|
253
259
|
|
254
260
|
@objc func videoBtnbuttonClicked() {
|
261
|
+
turnOnAndOffVideo()
|
262
|
+
}
|
263
|
+
func turnOnAndOffVideo(){
|
255
264
|
if (self.isVideoMute) {
|
256
265
|
self.publisher?.publishVideo = true
|
257
266
|
self.videoBtn.setImage(UIImage(named : "cameraOnWhite"), for: .normal)
|
@@ -294,6 +303,7 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
|
|
294
303
|
let settings = OTPublisherSettings()
|
295
304
|
settings.name = publisherName
|
296
305
|
guard let publisher = OTPublisher(delegate: self, settings: settings) else {
|
306
|
+
print("publisher create error")
|
297
307
|
return
|
298
308
|
}
|
299
309
|
self.publisher = publisher
|
@@ -305,6 +315,7 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
|
|
305
315
|
}
|
306
316
|
|
307
317
|
guard let publisherView = publisher.view else {
|
318
|
+
print("publisher view not created")
|
308
319
|
return
|
309
320
|
}
|
310
321
|
|
@@ -319,6 +330,10 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
|
|
319
330
|
func sessionDidDisconnect(_ session: OTSession) {
|
320
331
|
print("The client disconnected from the OpenTok session.")
|
321
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
|
+
}
|
322
337
|
self.dismiss(animated: true, completion: nil)
|
323
338
|
}
|
324
339
|
|
@@ -345,6 +360,9 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
|
|
345
360
|
}
|
346
361
|
|
347
362
|
subscriberView.frame = UIScreen.main.bounds
|
363
|
+
if(stream.videoType == .screen){
|
364
|
+
subscriberView.accessibilityValue = "from screen"
|
365
|
+
}
|
348
366
|
remoteView.addSubview(subscriberView)
|
349
367
|
}
|
350
368
|
|
@@ -356,16 +374,26 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
|
|
356
374
|
// self.session?.disconnect(nil)
|
357
375
|
// self.dismiss(animated: true, completion: nil)
|
358
376
|
// }
|
359
|
-
if let subStream = subscriber?.stream, subStream.streamId == stream.streamId,!isProvider {
|
377
|
+
if let subStream = subscriber?.stream, subStream.streamId == stream.streamId,!isProvider, stream.videoType != .screen {
|
360
378
|
// cleanupSubscriber()
|
361
379
|
let userInfo = ["userInfo": ["isProvider": isProvider]]
|
362
380
|
NotificationCenter.default.post(name: NSNotification.Name(NotificationNames.videoEnded),object: nil,userInfo: userInfo)
|
363
381
|
self.session?.disconnect(nil)
|
364
382
|
self.dismiss(animated: true, completion: nil)
|
365
383
|
}
|
366
|
-
|
367
|
-
|
368
|
-
|
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
|
+
|
369
397
|
|
370
398
|
}
|
371
399
|
|
@@ -387,7 +415,10 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
|
|
387
415
|
public func subscriberDidConnect(toStream subscriber: OTSubscriberKit) {
|
388
416
|
print("The subscriber did connect to the stream.")
|
389
417
|
subscriberImg.isHidden = true
|
390
|
-
|
418
|
+
if(subscriber.stream?.videoType != .screen){
|
419
|
+
showToast(message: "\(subscriberName) is joined the call")
|
420
|
+
}
|
421
|
+
|
391
422
|
}
|
392
423
|
|
393
424
|
public func subscriber(_ subscriber: OTSubscriberKit, didFailWithError error: OTError) {
|