瀏覽代碼

3128西班牙项目增加通话界面音量调节功能,同时解决通话中关闭声音后退出通话后再次通话无声问题

weizhengliang 1 年之前
父節點
當前提交
e4ebac5bf1

+ 1 - 0
android_host/src/main/h10_wke_1h/java/com/wdkl/ncs/android/component/nursehome/fragment/SipCallFragment.kt

@@ -65,6 +65,7 @@ class SipCallFragment: BaseCallFragment() {
         tv_volume.text = "" + volume/10
 
         VoiceManagerUtil.setCallVoice(activity, volume)
+        sipCore?.isMicEnabled = true
 
         //Log.e(TAG, "udpPort: ${sipCore!!.transports.udpPort}, tcpPort: ${sipCore!!.transports.tcpPort}")
         //Log.d(TAG, "callState: $callState, local sip: ${Constants.sip_id}, target sip: ${Constants.targetSipId}")

+ 1 - 0
android_host/src/main/h10_z3128_1h/java/com/wdkl/ncs/android/component/nursehome/fragment/SipCallFragment.kt

@@ -65,6 +65,7 @@ class SipCallFragment: BaseCallFragment() {
         tv_volume.text = "" + volume/10
 
         VoiceManagerUtil.setCallVoice(activity, volume)
+        sipCore?.isMicEnabled = true
 
         //Log.d(TAG, "callState: $callState, local sip: ${Constants.sip_id}, target sip: ${Constants.targetSipId}")
         when (callState) {

+ 59 - 0
android_host/src/main/h10_z3128_1h_chile/java/com/wdkl/ncs/android/component/nursehome/fragment/SkyCallFragment.kt

@@ -6,13 +6,16 @@ import android.os.Looper
 import android.os.SystemClock
 import android.util.Log
 import android.view.View
+import android.widget.SeekBar
 import com.alibaba.android.vlayout.VirtualLayoutManager
 import com.alibaba.fastjson.JSONObject
 import com.google.gson.Gson
 import com.wdkl.ncs.android.component.nursehome.R
 import com.wdkl.ncs.android.component.nursehome.adapter.BedItemAdapter
+import com.wdkl.ncs.android.component.nursehome.settingconfig.SettingConfig
 import com.wdkl.ncs.android.middleware.common.Constants
 import com.wdkl.ncs.android.component.nursehome.util.RingPlayHelper
+import com.wdkl.ncs.android.component.nursehome.util.VoiceManagerUtil
 import com.wdkl.ncs.android.lib.base.BaseApplication
 import com.wdkl.ncs.android.lib.utils.AppTool
 import com.wdkl.ncs.android.lib.utils.showMessage
@@ -57,6 +60,10 @@ class SkyCallFragment: BaseCallFragment(), CallSessionCallback {
     private var outGoing: Boolean = false
     private var acceptCall = false
 
+    private var speakerMute = false
+    private var micMute: Boolean = false // 是否关闭麦克风
+    private var volume = 60
+
     private var janusClient: JanusClient? = null
     private var room: Room?=null
     private var videoRoomCallback: VideoRoomCallback? = null
@@ -70,6 +77,16 @@ class SkyCallFragment: BaseCallFragment(), CallSessionCallback {
 
     override fun init() {
         initCountDownTimer()
+
+        volume = SettingConfig.getHostHandsFreePlayVolume(activity)
+        if (volume < 0 || volume > 100) {
+            volume = 60
+        }
+        call_volume_bar.progress = volume/10
+        tv_volume.text = "" + volume/10
+
+        VoiceManagerUtil.setCallVoice(activity, volume)
+
         //初始化 engine
         WebRTCEngine.getInstance().init(true, BaseApplication.appContext)
         //初始化 janusClient
@@ -183,6 +200,45 @@ class SkyCallFragment: BaseCallFragment(), CallSessionCallback {
             Constants.CALL_STATE = Constants.CALL_STANDBY
             DeviceChannel.calling = false
         }
+
+        sky_voice_call_speaker.setOnClickListener {
+            speakerMute = !speakerMute
+            Log.d(TAG,"Speaker enable: $speakerMute")
+
+            WebRTCEngine.getInstance().setVolumeMute(speakerMute)
+            sky_voice_call_speaker.isSelected = speakerMute
+        }
+
+        sky_voice_call_mute.setOnClickListener {
+            micMute = !micMute
+            Log.d(TAG,"静音切换: $micMute")
+
+            WebRTCEngine.getInstance().muteAudio(micMute)
+            sky_voice_call_mute.isSelected = micMute
+        }
+
+        call_volume_bar.setOnSeekBarChangeListener(object : SeekBar.OnSeekBarChangeListener{
+            override fun onProgressChanged(seekBar: SeekBar?, progress: Int, fromUser: Boolean) {
+                tv_volume.text = "" + progress
+                if (seekBar!!.progress <= 1) {
+                    tv_volume.text = "1"
+                } else {
+                    tv_volume.text = "" + progress
+                }
+            }
+
+            override fun onStartTrackingTouch(seekBar: SeekBar?) {
+                //
+            }
+
+            override fun onStopTrackingTouch(seekBar: SeekBar?) {
+                if (seekBar!!.progress <= 2) {
+                    VoiceManagerUtil.setCallVoice(activity, 20)
+                } else {
+                    VoiceManagerUtil.setCallVoice(activity, seekBar.progress*10)
+                }
+            }
+        })
     }
 
     override fun destroy() {
@@ -232,6 +288,9 @@ class SkyCallFragment: BaseCallFragment(), CallSessionCallback {
         sky_voice_call_timer.visibility = View.VISIBLE
         sky_voice_call_timer.base = SystemClock.elapsedRealtime()
         sky_voice_call_timer.start()
+        sky_voice_call_speaker.visibility = View.VISIBLE
+        sky_voice_call_mute.visibility = View.VISIBLE
+        ll_voice_volume_bar.visibility = View.VISIBLE
     }
 
     private fun cancelCall(fromId: Int, toId: Int?, interactionId: Int?) {

+ 66 - 7
android_host/src/main/h10_z3128_1h_chile/res/layout/sky_voice_call_layout.xml

@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="utf-8"?>
-<layout>
+<layout xmlns:app="http://schemas.android.com/apk/res-auto">
     <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
         android:layout_width="match_parent"
         android:layout_height="match_parent"
@@ -82,12 +82,71 @@
                     android:textColor="@color/white"
                     android:textSize="24sp" />
 
-                <ImageView
-                    android:id="@+id/sky_voice_call_hangup"
-                    android:layout_width="80dp"
-                    android:layout_height="80dp"
-                    android:layout_marginTop="20dp"
-                    android:src="@drawable/selector_call_hangup" />
+                <LinearLayout
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:layout_marginTop="20dp">
+
+                    <ImageView
+                        android:id="@+id/sky_voice_call_mute"
+                        android:layout_width="100dp"
+                        android:layout_height="100dp"
+                        android:layout_marginRight="40dp"
+                        android:src="@drawable/av_mute_selector"
+                        android:visibility="gone"/>
+
+                    <ImageView
+                        android:id="@+id/sky_voice_call_hangup"
+                        android:layout_width="100dp"
+                        android:layout_height="100dp"
+                        android:src="@drawable/selector_call_hangup" />
+
+                    <ImageView
+                        android:id="@+id/sky_voice_call_speaker"
+                        android:layout_width="100dp"
+                        android:layout_height="100dp"
+                        android:layout_marginLeft="40dp"
+                        android:src="@drawable/av_speaker_selector"
+                        android:visibility="gone"/>
+
+                </LinearLayout>
+            </LinearLayout>
+
+            <LinearLayout
+                android:id="@+id/ll_voice_volume_bar"
+                android:layout_width="60dp"
+                android:layout_height="match_parent"
+                android:layout_alignParentRight="true"
+                android:layout_marginRight="120dp"
+                android:layout_marginTop="100dp"
+                android:layout_marginBottom="100dp"
+                android:clipChildren="true"
+                android:orientation="vertical"
+                android:gravity="center"
+                android:visibility="gone">
+                <TextView
+                    android:id="@+id/tv_volume"
+                    android:layout_width="match_parent"
+                    android:layout_height="wrap_content"
+                    android:gravity="center"
+                    android:textSize="24sp"
+                    android:textColor="@color/title_text"/>
+
+                <com.wdkl.ncs.android.lib.widget.VerticalSeekBarWrapper
+                    android:layout_width="32dp"
+                    android:layout_height="match_parent">
+                    <com.wdkl.ncs.android.lib.widget.VerticalSeekBar
+                        android:id="@+id/call_volume_bar"
+                        android:layout_width="0dp"
+                        android:layout_height="0dp"
+                        android:padding="8dp"
+                        android:max="10"
+                        android:progress="6"
+                        android:splitTrack="false"
+                        android:progressDrawable="@drawable/seek_bar_bg"
+                        android:thumb="@drawable/seek_bar_thumb"
+                        app:seekBarRotation="CW270" /> <!-- Rotation: CW90 or CW270 -->
+                </com.wdkl.ncs.android.lib.widget.VerticalSeekBarWrapper>
             </LinearLayout>
         </RelativeLayout>
     </FrameLayout>

+ 4 - 0
janus/src/main/java/com/wdkl/ncs/janus/rtc/WebRTCEngine.java

@@ -408,6 +408,10 @@ public class WebRTCEngine {
         if (_localStream == null) {
             createLocalStream();
         }
+
+        //初始化打开声音通道
+        setVolumeMute(false);
+        muteAudio(false);
     }
 
     /**