video stream bug disconnect fixes

video-stream-floating
mosazaid 5 years ago
parent a1ab1e4f43
commit adab2d47d3

@ -182,8 +182,13 @@ class VideoStreamFloatingWidgetService : Service(), Session.SessionListener,
}
override fun onDestroy() {
mWindowManager?.removeView(floatingWidgetView)
// disconnectSession()
try {
mWindowManager?.removeView(floatingWidgetView)
} catch (e: Exception) {
Log.e("onDestroyService", "${e.localizedMessage}.")
}
// disconnectSession()
super.onDestroy()
}
@ -193,7 +198,12 @@ class VideoStreamFloatingWidgetService : Service(), Session.SessionListener,
cmTimer.stop()
stopForeground(true)
stopSelf()
videoCallResponseListener?.minimizeVideoEvent(false)
try {
mWindowManager?.removeView(floatingWidgetView)
} catch (e: Exception) {
Log.e("stopService", "${e.localizedMessage}.")
}
}
/* Add Floating Widget View to Window Manager */
@ -291,9 +301,20 @@ class VideoStreamFloatingWidgetService : Service(), Session.SessionListener,
arg0?.text = formattedCallTime
try {
notificationCompatBuilder.contentView.setChronometer(R.id.notify_timer, cmTimer.base, null, true)
notificationCompatBuilder.bigContentView.setChronometer(R.id.notify_timer, cmTimer.base, null, true)
} catch (e : Exception){}
notificationCompatBuilder.contentView.setChronometer(
R.id.notify_timer,
cmTimer.base,
null,
true
)
notificationCompatBuilder.bigContentView.setChronometer(
R.id.notify_timer,
cmTimer.base,
null,
true
)
} catch (e: Exception) {
}
// for change notification timer
if (mNotificationManagerCompat != null) {
@ -321,6 +342,17 @@ class VideoStreamFloatingWidgetService : Service(), Session.SessionListener,
mSession = Session.Builder(this, apiKey, sessionId).build()
mSession!!.setSessionListener(this)
mSession!!.connect(token)
mSession!!.setReconnectionListener(object : Session.ReconnectionListener {
override fun onReconnecting(session: Session?) {
}
override fun onReconnected(session: Session?) {
session?.connect(token)
session?.onResume()
}
})
} catch (e: Exception) {
e.printStackTrace()
}
@ -558,20 +590,26 @@ class VideoStreamFloatingWidgetService : Service(), Session.SessionListener,
}
fun onMinimizedClicked() {
if (isCircle){
if (isCircle) {
onMiniCircleClicked()
}
if (isFullScreen) {
windowManagerParams.width = 400
windowManagerParams.height = 600
mWindowManager?.updateViewLayout(floatingWidgetView, windowManagerParams)
try {
mWindowManager?.updateViewLayout(floatingWidgetView, windowManagerParams)
} catch (e: Exception) {
}
recordContainer.visibility = View.GONE
} else {
windowManagerParams.width = WindowManager.LayoutParams.MATCH_PARENT
windowManagerParams.height = WindowManager.LayoutParams.MATCH_PARENT
mWindowManager?.updateViewLayout(floatingWidgetView, windowManagerParams)
try {
mWindowManager?.updateViewLayout(floatingWidgetView, windowManagerParams)
} catch (e: Exception) {
}
if (isRecording) {
recordContainer.visibility = View.VISIBLE
@ -637,12 +675,18 @@ class VideoStreamFloatingWidgetService : Service(), Session.SessionListener,
windowManagerParams.width = 400
windowManagerParams.height = 600
mWindowManager?.updateViewLayout(floatingWidgetView, windowManagerParams)
try {
mWindowManager?.updateViewLayout(floatingWidgetView, windowManagerParams)
} catch (e: Exception) {
}
} else {
windowManagerParams.width = 300
windowManagerParams.height = 300
mWindowManager?.updateViewLayout(floatingWidgetView, windowManagerParams)
try {
mWindowManager?.updateViewLayout(floatingWidgetView, windowManagerParams)
} catch (e: Exception) {
}
}
isCircle = !isCircle
@ -728,10 +772,10 @@ class VideoStreamFloatingWidgetService : Service(), Session.SessionListener,
override fun onDisconnected(session: Session) {
Log.d(TAG, "onDisconnected: disconnected from session " + session.sessionId)
mSession = null
cmTimer.stop()
disconnectSession()
videoCallResponseListener?.minimizeVideoEvent(false)
// mSession = null
// cmTimer.stop()
// disconnectSession()
// videoCallResponseListener?.minimizeVideoEvent(false)
}
override fun onError(session: Session, opentokError: OpentokError) {
@ -1035,7 +1079,12 @@ class VideoStreamFloatingWidgetService : Service(), Session.SessionListener,
mRemoteViewsExpand.setTextViewText(R.id.notify_title, notificationData.mContentTitle)
mRemoteViewsExpand.setTextViewText(R.id.notify_content, notificationData.mContentText)
mRemoteViewsExpand.setOnClickPendingIntent(R.id.btn_end, endCallPendingIntent)
mRemoteViewsExpand.setChronometer(R.id.notify_timer, SystemClock.elapsedRealtime(), null, false)
mRemoteViewsExpand.setChronometer(
R.id.notify_timer,
SystemClock.elapsedRealtime(),
null,
false
)
notificationCompatBuilder
// BIG_TEXT_STYLE sets title and content for API 16 (4.1 and after).

@ -199,6 +199,7 @@ class VideoCallFragment : DialogFragment(), PermissionCallbacks, Session.Session
}
}
fun setCallListener(videoCallResponseListener: VideoCallResponseListener) {
this.videoCallResponseListener = videoCallResponseListener
}
@ -354,6 +355,8 @@ class VideoCallFragment : DialogFragment(), PermissionCallbacks, Session.Session
checkClientConnected()
handleVideoViewHeight(true)
if (appLang == "ar") {
progressBarLayout!!.layoutDirection = View.LAYOUT_DIRECTION_RTL
}

@ -33,8 +33,8 @@ class VideoCallService extends BaseService {
// kToken: startCallRes.openTokenID,
// kSessionId: startCallRes.openSessionID,
// kApiKey:'46209962',
kToken: "T1==cGFydG5lcl9pZD00NzI0Nzk1NCZzaWc9NGIyZDljOTY3YjFiNWU1YzUzNzFmMjIyNjJmNmEzY2Y5NzZjOTdlYzpzZXNzaW9uX2lkPTFfTVg0ME56STBOemsxTkg1LU1UWXlNekEyTlRRMU9EVXhObjVrVFRoMFlVdFJXaXRYTWpadFZGZHFhSGxZVGpOdE1UVi1mZyZjcmVhdGVfdGltZT0xNjIzMDY1NDk1Jm5vbmNlPTAuMjM2Mjk0NTIwMTkyOTA4OTcmcm9sZT1wdWJsaXNoZXImZXhwaXJlX3RpbWU9MTYyNTY1NzQ5NCZpbml0aWFsX2xheW91dF9jbGFzc19saXN0PQ==",
kSessionId: "1_MX40NzI0Nzk1NH5-MTYyMzA2NTQ1ODUxNn5kTTh0YUtRWitXMjZtVFdqaHlYTjNtMTV-fg",
kToken: "T1==cGFydG5lcl9pZD00NzI0Nzk1NCZzaWc9NGUyZjgxMjFlYTFkNzU5NjcxNDY2ZTM2ZjM3YTVhNTI2NGY0NTI2NzpzZXNzaW9uX2lkPTJfTVg0ME56STBOemsxTkg1LU1UWXlOVGN5TmpnMk5qZzNOMzQ1YUhCcGRtcDFXbVpDTDFkNE1qbDRkWFY2TTA4cmIySi1mZyZjcmVhdGVfdGltZT0xNjI1NzI2ODg5Jm5vbmNlPTAuNjc2Nzc4OTQxNjA1MTMxNSZyb2xlPXB1Ymxpc2hlciZleHBpcmVfdGltZT0xNjI4MzE4ODg4JmluaXRpYWxfbGF5b3V0X2NsYXNzX2xpc3Q9",
kSessionId: "2_MX40NzI0Nzk1NH5-MTYyNTcyNjg2Njg3N345aHBpdmp1WmZCL1d4Mjl4dXV6M08rb2J-fg",
kApiKey:'47247954',
vcId: patient.vcId,
isRecording: isRecording,

Loading…
Cancel
Save