Commit 698a04c6 by 万齐军

音量上报与挂断音效

parent 9a05908a
...@@ -10,6 +10,7 @@ import android.hardware.Sensor ...@@ -10,6 +10,7 @@ import android.hardware.Sensor
import android.hardware.SensorEvent import android.hardware.SensorEvent
import android.hardware.SensorEventListener import android.hardware.SensorEventListener
import android.hardware.SensorManager import android.hardware.SensorManager
import android.media.AudioManager
import android.media.MediaPlayer import android.media.MediaPlayer
import android.net.Uri import android.net.Uri
import android.os.* import android.os.*
...@@ -29,6 +30,7 @@ import com.hjq.permissions.XXPermissions ...@@ -29,6 +30,7 @@ import com.hjq.permissions.XXPermissions
import com.ydl.audioim.bean.AgoraInvitationBean import com.ydl.audioim.bean.AgoraInvitationBean
import com.ydl.audioim.bean.AgoraLogInfoBean import com.ydl.audioim.bean.AgoraLogInfoBean
import com.ydl.audioim.contract.IAudioHomeActivityContract import com.ydl.audioim.contract.IAudioHomeActivityContract
import com.ydl.audioim.http.AudioNetAPi
import com.ydl.audioim.http.command.ConnectCommand import com.ydl.audioim.http.command.ConnectCommand
import com.ydl.audioim.http.command.ConnectExceptionCommand import com.ydl.audioim.http.command.ConnectExceptionCommand
import com.ydl.audioim.http.command.NoticePushCommand import com.ydl.audioim.http.command.NoticePushCommand
...@@ -42,6 +44,7 @@ import com.ydl.audioim.utils.DateUtils ...@@ -42,6 +44,7 @@ import com.ydl.audioim.utils.DateUtils
import com.ydl.audioim.utils.onConfideEvent import com.ydl.audioim.utils.onConfideEvent
import com.ydl.audioim.widget.AxbConfirmDialog import com.ydl.audioim.widget.AxbConfirmDialog
import com.ydl.audioim.widget.ZDialog import com.ydl.audioim.widget.ZDialog
import com.ydl.devicesidlib.DeviceIDHelper
import com.ydl.webview.H5Params import com.ydl.webview.H5Params
import com.ydl.webview.NewH5Activity import com.ydl.webview.NewH5Activity
import com.ydl.webview.RefreshWebEvent import com.ydl.webview.RefreshWebEvent
...@@ -64,6 +67,7 @@ import com.ydl.ydlcommon.utils.log.AliYunRichLogsHelper ...@@ -64,6 +67,7 @@ import com.ydl.ydlcommon.utils.log.AliYunRichLogsHelper
import com.ydl.ydlcommon.utils.log.LogHelper import com.ydl.ydlcommon.utils.log.LogHelper
import com.ydl.ydlcommon.utils.log.XLog import com.ydl.ydlcommon.utils.log.XLog
import com.ydl.ydlcommon.utils.remind.ToastHelper import com.ydl.ydlcommon.utils.remind.ToastHelper
import com.ydl.ydlnet.YDLHttpUtils
import com.yidianling.common.tools.ToastUtil import com.yidianling.common.tools.ToastUtil
import com.yidianling.im.api.bean.IMRegisterObserverCustomNotificationCallBack import com.yidianling.im.api.bean.IMRegisterObserverCustomNotificationCallBack
import com.yidianling.im.api.service.IImService import com.yidianling.im.api.service.IImService
...@@ -72,8 +76,10 @@ import de.greenrobot.event.EventBus ...@@ -72,8 +76,10 @@ import de.greenrobot.event.EventBus
import io.agora.rtc.Constants import io.agora.rtc.Constants
import io.agora.rtc.IRtcEngineEventHandler import io.agora.rtc.IRtcEngineEventHandler
import io.reactivex.Observable import io.reactivex.Observable
import io.reactivex.Single
import io.reactivex.android.schedulers.AndroidSchedulers import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.disposables.Disposable import io.reactivex.disposables.Disposable
import io.reactivex.functions.Consumer
import io.reactivex.schedulers.Schedulers import io.reactivex.schedulers.Schedulers
import kotlinx.android.synthetic.main.audioim_activity_audio_home.* import kotlinx.android.synthetic.main.audioim_activity_audio_home.*
import java.util.* import java.util.*
...@@ -90,6 +96,9 @@ import java.util.concurrent.TimeUnit ...@@ -90,6 +96,9 @@ import java.util.concurrent.TimeUnit
class AudioHomeActivity : class AudioHomeActivity :
BaseMvpActivity<IAudioHomeActivityContract.View, IAudioHomeActivityContract.Presenter>(), BaseMvpActivity<IAudioHomeActivityContract.View, IAudioHomeActivityContract.Presenter>(),
IAudioHomeActivityContract.View, SensorEventListener { IAudioHomeActivityContract.View, SensorEventListener {
companion object {
const val EFFECT_HANGUP = 3001
}
/** /**
* 专家头像地址 * 专家头像地址
...@@ -526,6 +535,7 @@ class AudioHomeActivity : ...@@ -526,6 +535,7 @@ class AudioHomeActivity :
return R.layout.audioim_activity_audio_home return R.layout.audioim_activity_audio_home
} }
@SuppressLint("CheckResult")
override fun initDataAndEvent() { override fun initDataAndEvent() {
//状态栏颜色 //状态栏颜色
setWindowStatusBarColor() setWindowStatusBarColor()
...@@ -553,6 +563,22 @@ class AudioHomeActivity : ...@@ -553,6 +563,22 @@ class AudioHomeActivity :
requestPermission() requestPermission()
findRouteService(IImService::class.java).registerObserveCustomNotification(notificationCallback) findRouteService(IImService::class.java).registerObserveCustomNotification(notificationCallback)
Single.create<Int> {
val audioManager = getSystemService(Context.AUDIO_SERVICE) as AudioManager
val callMax = audioManager.getStreamMaxVolume(AudioManager.STREAM_VOICE_CALL)
val call = audioManager.getStreamVolume(AudioManager.STREAM_VOICE_CALL)
val callPercent = (100F * call / callMax).toInt()
it.onSuccess(callPercent)
}
.subscribeOn(Schedulers.io())
.subscribe(Consumer {
val req = hashMapOf(
"deviceId" to DeviceIDHelper.getInstance().deviceId,
"voice" to it
)
YDLHttpUtils.obtainApi(AudioNetAPi::class.java).report(req).subscribe()
})
ActionCountUtils.record("call_phone_page", "call_phone_page_visit", listenerUid ?: "0", "1") ActionCountUtils.record("call_phone_page", "call_phone_page_visit", listenerUid ?: "0", "1")
} }
...@@ -1462,6 +1488,7 @@ class AudioHomeActivity : ...@@ -1462,6 +1488,7 @@ class AudioHomeActivity :
//播放结束音频 //播放结束音频
playFinishMusic() playFinishMusic()
// 声网离开房间 // 声网离开房间
voiceManage?.getVoiceApi()?.playEffect(EFFECT_HANGUP, "res://raw/${R.raw.effect_hand_up}")
voiceManage?.getVoiceApi()?.leaveChannel() voiceManage?.getVoiceApi()?.leaveChannel()
} }
} }
...@@ -1649,6 +1676,7 @@ class AudioHomeActivity : ...@@ -1649,6 +1676,7 @@ class AudioHomeActivity :
if (null != voiceManage && null != voiceManage?.getVoiceApi()) { if (null != voiceManage && null != voiceManage?.getVoiceApi()) {
if (!isLeavelChannel) { if (!isLeavelChannel) {
// 声网离开房间 // 声网离开房间
voiceManage?.getVoiceApi()?.playEffect(EFFECT_HANGUP, "res://raw/${R.raw.effect_hand_up}")
voiceManage?.getVoiceApi()?.leaveChannel() voiceManage?.getVoiceApi()?.leaveChannel()
} }
// voiceManage?.getVoiceApi()?.destroy() // voiceManage?.getVoiceApi()?.destroy()
......
...@@ -10,6 +10,7 @@ import android.hardware.Sensor ...@@ -10,6 +10,7 @@ import android.hardware.Sensor
import android.hardware.SensorEvent import android.hardware.SensorEvent
import android.hardware.SensorEventListener import android.hardware.SensorEventListener
import android.hardware.SensorManager import android.hardware.SensorManager
import android.media.AudioManager
import android.net.Uri import android.net.Uri
import android.os.PowerManager import android.os.PowerManager
import android.provider.Settings import android.provider.Settings
...@@ -25,6 +26,7 @@ import com.google.gson.Gson ...@@ -25,6 +26,7 @@ import com.google.gson.Gson
import com.tbruyelle.rxpermissions2.RxPermissions import com.tbruyelle.rxpermissions2.RxPermissions
import com.ydl.audioim.R import com.ydl.audioim.R
import com.ydl.audioim.YDLavManager import com.ydl.audioim.YDLavManager
import com.ydl.audioim.http.AudioNetAPi
import com.ydl.audioim.http.command.ConnectExceptionCommand import com.ydl.audioim.http.command.ConnectExceptionCommand
import com.ydl.audioim.http.command.PayLoad import com.ydl.audioim.http.command.PayLoad
import com.ydl.audioim.player.AudioPlayer import com.ydl.audioim.player.AudioPlayer
...@@ -35,6 +37,7 @@ import com.ydl.consultantim.event.AudioHomeEvent ...@@ -35,6 +37,7 @@ import com.ydl.consultantim.event.AudioHomeEvent
import com.ydl.consultantim.presenter.ConsultantAudioHomePresenterImpl import com.ydl.consultantim.presenter.ConsultantAudioHomePresenterImpl
import com.ydl.consultantim.utils.ConsultantAudioUtils import com.ydl.consultantim.utils.ConsultantAudioUtils
import com.ydl.consultantim.utils.VibratorUtil import com.ydl.consultantim.utils.VibratorUtil
import com.ydl.devicesidlib.DeviceIDHelper
import com.ydl.ydl_av.chat.bean.AudioMessageBean import com.ydl.ydl_av.chat.bean.AudioMessageBean
import com.ydl.ydl_av.voice.listener.IYDLVoiceEventHandler import com.ydl.ydl_av.voice.listener.IYDLVoiceEventHandler
import com.ydl.ydl_av.voice.listener.RtcNetInterface import com.ydl.ydl_av.voice.listener.RtcNetInterface
...@@ -54,13 +57,16 @@ import com.ydl.ydlcommon.utils.log.AliYunRichLogsHelper ...@@ -54,13 +57,16 @@ import com.ydl.ydlcommon.utils.log.AliYunRichLogsHelper
import com.ydl.ydlcommon.utils.log.LogHelper import com.ydl.ydlcommon.utils.log.LogHelper
import com.ydl.ydlcommon.utils.log.XLog import com.ydl.ydlcommon.utils.log.XLog
import com.ydl.ydlcommon.utils.remind.ToastHelper import com.ydl.ydlcommon.utils.remind.ToastHelper
import com.ydl.ydlnet.YDLHttpUtils
import com.yidianling.user.api.service.IUserService import com.yidianling.user.api.service.IUserService
import de.greenrobot.event.EventBus import de.greenrobot.event.EventBus
import io.agora.rtc.Constants import io.agora.rtc.Constants
import io.agora.rtc.IRtcEngineEventHandler import io.agora.rtc.IRtcEngineEventHandler
import io.reactivex.Observable import io.reactivex.Observable
import io.reactivex.Single
import io.reactivex.android.schedulers.AndroidSchedulers import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.disposables.Disposable import io.reactivex.disposables.Disposable
import io.reactivex.functions.Consumer
import io.reactivex.schedulers.Schedulers import io.reactivex.schedulers.Schedulers
import kotlinx.android.synthetic.main.audioim_cativity_consultant_audio_home.* import kotlinx.android.synthetic.main.audioim_cativity_consultant_audio_home.*
import java.util.* import java.util.*
...@@ -492,6 +498,7 @@ class ConsultantAudioHomeActivity : ...@@ -492,6 +498,7 @@ class ConsultantAudioHomeActivity :
@SuppressLint("CheckResult")
override fun initDataAndEvent() { override fun initDataAndEvent() {
EventBus.getDefault().register(this) EventBus.getDefault().register(this)
callEventSave("30", "进入接听界面") callEventSave("30", "进入接听界面")
...@@ -507,6 +514,21 @@ class ConsultantAudioHomeActivity : ...@@ -507,6 +514,21 @@ class ConsultantAudioHomeActivity :
initData() initData()
//获取声网频道号 //获取声网频道号
getChannelToken() getChannelToken()
Single.create<Int> {
val audioManager = getSystemService(Context.AUDIO_SERVICE) as AudioManager
val callMax = audioManager.getStreamMaxVolume(AudioManager.STREAM_VOICE_CALL)
val call = audioManager.getStreamVolume(AudioManager.STREAM_VOICE_CALL)
val callPercent = (100F * call / callMax).toInt()
it.onSuccess(callPercent)
}
.subscribeOn(Schedulers.io())
.subscribe(Consumer {
val req = hashMapOf(
"deviceId" to DeviceIDHelper.getInstance().deviceId,
"voice" to it
)
YDLHttpUtils.obtainApi(AudioNetAPi::class.java).report(req).subscribe()
})
} }
private fun setWindowStatusBarColor() { private fun setWindowStatusBarColor() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment