Skip to content

Commit

Permalink
点击屏幕分享小窗口时要停掉分享
Browse files Browse the repository at this point in the history
  • Loading branch information
imhao183 committed May 19, 2021
1 parent c5239ac commit 31fb242
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 5 deletions.
30 changes: 25 additions & 5 deletions uikit/src/main/java/cn/wildfire/chat/kit/voip/VoipCallService.java
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,9 @@ private void checkCallState() {
} else {
updateNotification(session);
if (showFloatingWindow && session.getState() == AVEngineKit.CallState.Connected) {
if (session.isAudioOnly()) {
if(session.isScreenSharing()) {
showScreenSharingView(session);
} else if (session.isAudioOnly()) {
showAudioView(session);
} else {
showVideoView(session);
Expand Down Expand Up @@ -222,7 +224,9 @@ private void showFloatingWindow(AVEngineKit.CallSession session) {
if (session.getState() != AVEngineKit.CallState.Connected) {
showUnConnectedCallInfo(session);
} else {
if (session.isAudioOnly()) {
if(session.isScreenSharing()) {
showScreenSharingView(session);
} else if (session.isAudioOnly()) {
showAudioView(session);
} else {
showVideoView(session);
Expand Down Expand Up @@ -267,6 +271,18 @@ private void showUnConnectedCallInfo(AVEngineKit.CallSession session) {
timeView.setText(title);
}

private void showScreenSharingView(AVEngineKit.CallSession session) {
FrameLayout remoteVideoFrameLayout = view.findViewById(R.id.remoteVideoFrameLayout);
if (remoteVideoFrameLayout.getVisibility() == View.VISIBLE) {
remoteVideoFrameLayout.setVisibility(View.GONE);
wm.removeView(view);
wm.addView(view, params);
}
view.findViewById(R.id.screenSharingTextView).setVisibility(View.VISIBLE);
view.findViewById(R.id.durationTextView).setVisibility(View.GONE);
view.findViewById(R.id.av_media_type).setVisibility(View.GONE);
}

private void showAudioView(AVEngineKit.CallSession session) {
FrameLayout remoteVideoFrameLayout = view.findViewById(R.id.remoteVideoFrameLayout);
if (remoteVideoFrameLayout.getVisibility() == View.VISIBLE) {
Expand Down Expand Up @@ -346,9 +362,13 @@ private void showVideoView(AVEngineKit.CallSession session) {
}

private void clickToResume() {
if (rendererInitialized) {
AVEngineKit.CallSession session = AVEngineKit.Instance().getCurrentSession();
if (session != null) {
AVEngineKit.CallSession session = AVEngineKit.Instance().getCurrentSession();
if (session != null) {
if(session.isScreenSharing()) {
session.stopScreenShare();
}

if (rendererInitialized) {
session.resetRenderer();
}
}
Expand Down
10 changes: 10 additions & 0 deletions uikit/src/main/res-av/layout/av_voip_float_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,16 @@
android:layout_gravity="center"
android:src="@drawable/av_float_audio" />

<TextView
android:id="@+id/screenSharingTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:text="停止分享"
android:textColor="#0195ff"
android:visibility="gone" />

<TextView
android:id="@+id/durationTextView"
android:layout_width="wrap_content"
Expand Down

0 comments on commit 31fb242

Please sign in to comment.