|
@@ -1,5 +1,6 @@
|
|
package com.wdkl.ncs.android.component.home.service
|
|
package com.wdkl.ncs.android.component.home.service
|
|
|
|
|
|
|
|
+import android.annotation.SuppressLint
|
|
import android.content.Context
|
|
import android.content.Context
|
|
import android.content.Intent
|
|
import android.content.Intent
|
|
import android.content.IntentFilter
|
|
import android.content.IntentFilter
|
|
@@ -74,6 +75,7 @@ class WdKeepAliveService : AbsWorkService() {
|
|
private var channelImList = ArrayList<ChannelImDO>()
|
|
private var channelImList = ArrayList<ChannelImDO>()
|
|
//当前播放的群留言id
|
|
//当前播放的群留言id
|
|
private var channelImId = 0
|
|
private var channelImId = 0
|
|
|
|
+ private var waitingLoop = false
|
|
|
|
|
|
private var warningTips = false
|
|
private var warningTips = false
|
|
private val keepHandler: Handler = object : Handler(Looper.getMainLooper()) {
|
|
private val keepHandler: Handler = object : Handler(Looper.getMainLooper()) {
|
|
@@ -312,6 +314,21 @@ class WdKeepAliveService : AbsWorkService() {
|
|
HandleTcpConnect.instance.tcpReConnectWithMsgShow()
|
|
HandleTcpConnect.instance.tcpReConnectWithMsgShow()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ } else {
|
|
|
|
+ //通话中或正在留言时有新的群留言进来则将其加入群留言队列中,待留言结束后自动播放
|
|
|
|
+ channelImList.add(channelData)
|
|
|
|
+ if (!waitingLoop) {
|
|
|
|
+ Thread {
|
|
|
|
+ while (DeviceChannel.calling || RecordHelper.getInstance().isRecording) {
|
|
|
|
+ waitingLoop = true
|
|
|
|
+ Thread.sleep(500)
|
|
|
|
+ }
|
|
|
|
+ waitingLoop = false
|
|
|
|
+ if (channelImList.size > 0) {
|
|
|
|
+ startPlayChannelIm(channelImList.get(0))
|
|
|
|
+ }
|
|
|
|
+ }.start()
|
|
|
|
+ }
|
|
}
|
|
}
|
|
} else if (tcpModel.action == TcpAction.IMAction.MSG) {
|
|
} else if (tcpModel.action == TcpAction.IMAction.MSG) {
|
|
//如果当前不在通话中则直接播放语音留言,并将该记录置为已读状态或当前正在留言中则等待留言结束再切换到留言事件界面
|
|
//如果当前不在通话中则直接播放语音留言,并将该记录置为已读状态或当前正在留言中则等待留言结束再切换到留言事件界面
|
|
@@ -608,12 +625,20 @@ class WdKeepAliveService : AbsWorkService() {
|
|
if (channelImList.size > 0) {
|
|
if (channelImList.size > 0) {
|
|
imPlayState = 2
|
|
imPlayState = 2
|
|
channelImId = channelImList.get(0).id
|
|
channelImId = channelImList.get(0).id
|
|
|
|
+ sendChannelImRead(channelImList.get(0))
|
|
MediaPlayHelper.getInstance().playUrlMusic(ApiManager.urlManager.device_url + channelImList.get(0).audioPath, 1f, false)
|
|
MediaPlayHelper.getInstance().playUrlMusic(ApiManager.urlManager.device_url + channelImList.get(0).audioPath, 1f, false)
|
|
} else {
|
|
} else {
|
|
imPlayState = 0
|
|
imPlayState = 0
|
|
}
|
|
}
|
|
ImPlayDialogHelper.dismissIMDialog()
|
|
ImPlayDialogHelper.dismissIMDialog()
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ //电话时停止播放留言并清除群留言列表
|
|
|
|
+ Constants.EVENT_PHONE_CALL -> {
|
|
|
|
+ channelImList.clear()
|
|
|
|
+ MediaPlayHelper.getInstance().stopMusic(true)
|
|
|
|
+ imPlayState = 0
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -705,15 +730,33 @@ class WdKeepAliveService : AbsWorkService() {
|
|
if ((imPlayState == 2 || imPlayState == 1) && MediaPlayHelper.getInstance().isMediaPlaying()) {
|
|
if ((imPlayState == 2 || imPlayState == 1) && MediaPlayHelper.getInstance().isMediaPlaying()) {
|
|
channelImList.add(channelImDO)
|
|
channelImList.add(channelImDO)
|
|
} else {
|
|
} else {
|
|
- imPlayState = 2
|
|
|
|
- showMessage("播放群留言...")
|
|
|
|
- MediaPlayHelper.getInstance().stopMusic(true)
|
|
|
|
- SoundPoolManager.getInstance().playSound(4)
|
|
|
|
|
|
+ startPlayChannelIm(channelImDO)
|
|
}
|
|
}
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
- AppTool.Time.delay(1000) {
|
|
|
|
- channelImId = channelImDO.id
|
|
|
|
- MediaPlayHelper.getInstance().playUrlMusic(ApiManager.urlManager.device_url + channelImDO.audioPath, 1f, false)
|
|
|
|
|
|
+ private fun startPlayChannelIm(channelIm: ChannelImDO) {
|
|
|
|
+ imPlayState = 2
|
|
|
|
+ showMessage("播放群留言...")
|
|
|
|
+ MediaPlayHelper.getInstance().stopMusic(true)
|
|
|
|
+ SoundPoolManager.getInstance().playSound(4)
|
|
|
|
+ AppTool.Time.delay(1000) {
|
|
|
|
+ imPlayState = 2
|
|
|
|
+ channelImId = channelIm.id
|
|
|
|
+ sendChannelImRead(channelIm)
|
|
|
|
+ MediaPlayHelper.getInstance().playUrlMusic(ApiManager.urlManager.device_url + channelIm.audioPath, 1f, false)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @SuppressLint("CheckResult")
|
|
|
|
+ private fun sendChannelImRead(channelIm: ChannelImDO) {
|
|
|
|
+ val imTcpModel = ChannelImUtil.channelImRead(Constants.deviceId, channelIm)
|
|
|
|
+ NettyClient.instance.sendMsg(imTcpModel.toJson()).subscribe {
|
|
|
|
+ if (it) {
|
|
|
|
+ Log.d(TAG, "TCP.发送消息完成")
|
|
|
|
+ } else {
|
|
|
|
+ Log.e(TAG, "TCP.发送消息失败")
|
|
|
|
+ HandleTcpConnect.instance.tcpReConnectWithMsgShow()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|